Skip to content

Commit

Permalink
Merge pull request #2100 from jamescowens/remove_comparesnapshotaccrual
Browse files Browse the repository at this point in the history
rpc: Remove obsolete comparesnapshotaccrual RPC function
  • Loading branch information
jamescowens authored Apr 12, 2021
2 parents c7b373c + d115c02 commit d1cfd34
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 73 deletions.
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

0 comments on commit d1cfd34

Please sign in to comment.