@@ -898,49 +898,40 @@ UniValue explainmagnitude(const UniValue& params, bool fHelp)
898
898
899
899
UniValue lifetime (const UniValue& params, bool fHelp )
900
900
{
901
- if (fHelp || params.size () != 0 )
901
+ if (fHelp || params.size () > 1 )
902
902
throw runtime_error (
903
- " lifetime\n "
903
+ " lifetime [cpid] \n "
904
904
" \n "
905
- " Displays information for the lifetime of your cpid in the network \n " );
905
+ " Displays research rewards for the lifetime of a CPID. \n " );
906
906
907
- UniValue results (UniValue::VARR);
908
- UniValue c (UniValue::VOBJ);
909
- UniValue res (UniValue::VOBJ );
907
+ const NN::MiningId mining_id = params. size () > 0
908
+ ? NN::MiningId::Parse (params[ 0 ]. get_str ())
909
+ : NN::Researcher::Get ()-> Id ( );
910
910
911
- const NN::CpidOption cpid = NN::Researcher::Get ()->Id ().TryCpid ();
912
- std::string Narr = ToString (GetAdjustedTime ());
911
+ if (!mining_id.Valid ()) {
912
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid CPID." );
913
+ }
913
914
914
- c.pushKV (" Lifetime Payments Report" , Narr);
915
- results.push_back (c);
915
+ const NN::CpidOption cpid = mining_id.TryCpid ();
916
916
917
917
if (!cpid) {
918
- return results ;
918
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " No data for investor. " ) ;
919
919
}
920
920
921
- LOCK (cs_main );
921
+ UniValue results (UniValue::VOBJ );
922
922
923
- CBlockIndex* pindex = pindexGenesisBlock ;
923
+ LOCK (cs_main) ;
924
924
925
- while (pindex->nHeight < pindexBest->nHeight )
925
+ for (const CBlockIndex* pindex = pindexGenesisBlock;
926
+ pindex;
927
+ pindex = pindex->pnext )
926
928
{
927
- pindex = pindex->pnext ;
928
-
929
- if (pindex==NULL || !pindex->IsInMainChain ())
930
- continue ;
931
-
932
- if (pindex == pindexBest)
933
- break ;
934
-
935
- if (pindex->GetMiningId () == *cpid && (pindex->nResearchSubsidy > 0 ))
936
- res.pushKV (ToString (pindex->nHeight ), ValueFromAmount (pindex->nResearchSubsidy ));
929
+ if (pindex->nResearchSubsidy > 0 && pindex->GetMiningId () == *cpid) {
930
+ results.pushKV (
931
+ std::to_string (pindex->nHeight ),
932
+ ValueFromAmount (pindex->nResearchSubsidy ));
933
+ }
937
934
}
938
- // 8-14-2015
939
- const NN::ResearchAccount account = NN::Tally::GetAccount (*cpid);
940
-
941
- res.pushKV (" RA Magnitude Sum" , (int )account.m_total_magnitude );
942
- res.pushKV (" RA Accuracy" , (int )account.m_accuracy );
943
- results.push_back (res);
944
935
945
936
return results;
946
937
}
0 commit comments