Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: Remove obsolete comparesnapshotaccrual RPC function #2100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,77 +647,6 @@ UniValue listresearcheraccounts(const UniValue& params, bool fHelp)
return result;
}

UniValue comparesnapshotaccrual(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"comparesnapshotaccrual\n"
"\n"
"Compare snapshot and legacy accrual for active CPIDs.\n");

const int64_t now = GetAdjustedTime();

size_t active_account_count = 0;
int64_t legacy_total = 0;
int64_t snapshot_total = 0;

UniValue result(UniValue::VOBJ);

LOCK(cs_main);

if (!IsV11Enabled(nBestHeight + 1)) {
throw JSONRPCError(RPC_INVALID_REQUEST, "Wait for block v11 protocol");
}

for (const auto& account_pair : GRC::Tally::Accounts()) {
const GRC::Cpid& cpid = account_pair.first;
const GRC::ResearchAccount& account = account_pair.second;

const GRC::AccrualComputer legacy = GRC::Tally::GetLegacyComputer(cpid, now, pindexBest);
const GRC::AccrualComputer snapshot = GRC::Tally::GetSnapshotComputer(cpid, now, pindexBest);

const int64_t legacy_accrual = legacy->RawAccrual();
const int64_t snapshot_accrual = snapshot->RawAccrual();

if (legacy_accrual == 0 && snapshot_accrual == 0) {
if (!account.IsNew() && !account.IsActive(pindexBest->nHeight)) {
continue;
}
}

UniValue accrual(UniValue::VOBJ);

accrual.pushKV("legacy", ValueFromAmount(legacy_accrual));
accrual.pushKV("snapshot", ValueFromAmount(snapshot_accrual));

//UniValue params(UniValue::VARR);
//params.push_back(cpid.ToString());
//accrual.pushKV("audit", auditdeltaaccrual(params, false));

result.pushKV(cpid.ToString(), accrual);

legacy_total += legacy_accrual;
snapshot_total += snapshot_accrual;
++active_account_count;
}

if (!active_account_count) {
throw JSONRPCError(RPC_MISC_ERROR, "There are no active accounts.");
}

UniValue summary(UniValue::VOBJ);

summary.pushKV("active_accounts", (uint64_t)active_account_count);
summary.pushKV("legacy_total", ValueFromAmount(legacy_total));
summary.pushKV("legacy_average", ValueFromAmount(legacy_total / active_account_count));
summary.pushKV("snapshot_total", ValueFromAmount(snapshot_total));
summary.pushKV("snapshot_average", ValueFromAmount(snapshot_total / active_account_count));

result.pushKV("summary", summary);

return result;
}

UniValue inspectaccrualsnapshot(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
Expand Down
1 change: 0 additions & 1 deletion src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ static const CRPCCommand vRPCCommands[] =
{ "auditsnapshotaccrual", &auditsnapshotaccrual, cat_developer },
{ "auditsnapshotaccruals", &auditsnapshotaccruals, cat_developer },
{ "addkey", &addkey, cat_developer },
{ "comparesnapshotaccrual", &comparesnapshotaccrual, cat_developer },
{ "currentcontractaverage", &currentcontractaverage, cat_developer },
{ "debug", &debug, cat_developer },
{ "dumpcontracts", &dumpcontracts, cat_developer },
Expand Down
1 change: 0 additions & 1 deletion src/rpc/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ extern UniValue superblocks(const UniValue& params, bool fHelp);
extern UniValue auditsnapshotaccrual(const UniValue& params, bool fHelp);
extern UniValue auditsnapshotaccruals(const UniValue& params, bool fHelp);
extern UniValue addkey(const UniValue& params, bool fHelp);
extern UniValue comparesnapshotaccrual(const UniValue& params, bool fHelp);
extern UniValue currentcontractaverage(const UniValue& params, bool fHelp);
extern UniValue debug(const UniValue& params, bool fHelp);
extern UniValue dumpcontracts(const UniValue& params, bool fHelp);
Expand Down