Skip to content
Merged
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
51 changes: 21 additions & 30 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,49 +898,40 @@ UniValue explainmagnitude(const UniValue& params, bool fHelp)

UniValue lifetime(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
if (fHelp || params.size() > 1)
throw runtime_error(
"lifetime\n"
"lifetime [cpid]\n"
"\n"
"Displays information for the lifetime of your cpid in the network\n");
"Displays research rewards for the lifetime of a CPID.\n");

UniValue results(UniValue::VARR);
UniValue c(UniValue::VOBJ);
UniValue res(UniValue::VOBJ);
const NN::MiningId mining_id = params.size() > 0
? NN::MiningId::Parse(params[0].get_str())
: NN::Researcher::Get()->Id();

const NN::CpidOption cpid = NN::Researcher::Get()->Id().TryCpid();
std::string Narr = ToString(GetAdjustedTime());
if (!mining_id.Valid()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid CPID.");
}

c.pushKV("Lifetime Payments Report", Narr);
results.push_back(c);
const NN::CpidOption cpid = mining_id.TryCpid();

if (!cpid) {
return results;
throw JSONRPCError(RPC_INVALID_PARAMETER, "No data for investor.");
}

LOCK(cs_main);
UniValue results(UniValue::VOBJ);

CBlockIndex* pindex = pindexGenesisBlock;
LOCK(cs_main);

while (pindex->nHeight < pindexBest->nHeight)
for (const CBlockIndex* pindex = pindexGenesisBlock;
pindex;
pindex = pindex->pnext)
{
pindex = pindex->pnext;

if (pindex==NULL || !pindex->IsInMainChain())
continue;

if (pindex == pindexBest)
break;

if (pindex->GetMiningId() == *cpid && (pindex->nResearchSubsidy > 0))
res.pushKV(ToString(pindex->nHeight), ValueFromAmount(pindex->nResearchSubsidy));
if (pindex->nResearchSubsidy > 0 && pindex->GetMiningId() == *cpid) {
results.pushKV(
std::to_string(pindex->nHeight),
ValueFromAmount(pindex->nResearchSubsidy));
}
}
//8-14-2015
const NN::ResearchAccount account = NN::Tally::GetAccount(*cpid);

res.pushKV("RA Magnitude Sum", (int)account.m_total_magnitude);
res.pushKV("RA Accuracy", (int)account.m_accuracy);
results.push_back(res);

return results;
}
Expand Down