Skip to content

Commit da40fd2

Browse files
authored
Merge pull request #1599 from cyrossignol/superblocks-rpc
Add more data to the "superblocks" RPC output
2 parents 4898cf9 + 2ba144b commit da40fd2

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/rpcblockchain.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,12 +1876,6 @@ UniValue execute(const UniValue& params, bool fHelp)
18761876
UniValue SuperblockReport(int lookback, bool displaycontract, std::string cpid)
18771877
{
18781878
UniValue results(UniValue::VARR);
1879-
UniValue c(UniValue::VOBJ);
1880-
std::string Narr = ToString(GetAdjustedTime());
1881-
c.pushKV("SuperBlock Report (14 days)",Narr);
1882-
if (!cpid.empty()) c.pushKV("CPID",cpid);
1883-
1884-
results.push_back(c);
18851879

18861880
int nMaxDepth = nBestHeight;
18871881
int nLookback = BLOCKS_PER_DAY * lookback;
@@ -1894,6 +1888,8 @@ UniValue SuperblockReport(int lookback, bool displaycontract, std::string cpid)
18941888
pblockindex = pblockindex->pprev;
18951889
}
18961890

1891+
const NN::CpidOption cpid_parsed = NN::MiningId::Parse(cpid).TryCpid();
1892+
18971893
while (pblockindex->nHeight > nMinDepth)
18981894
{
18991895
if (!pblockindex || !pblockindex->pprev) return results;
@@ -1909,12 +1905,21 @@ UniValue SuperblockReport(int lookback, bool displaycontract, std::string cpid)
19091905
const NN::Superblock& superblock = claim->m_superblock;
19101906

19111907
UniValue c(UniValue::VOBJ);
1912-
c.pushKV("Block #" + ToString(pblockindex->nHeight),pblockindex->GetBlockHash().GetHex());
1913-
c.pushKV("Date",TimestampToHRDate(pblockindex->nTime));
1914-
c.pushKV("Average Mag", superblock.m_cpids.AverageMagnitude());
1915-
c.pushKV("Wallet Version", claim->m_client_version);
1908+
c.pushKV("height", ToString(pblockindex->nHeight));
1909+
c.pushKV("block", pblockindex->GetBlockHash().GetHex());
1910+
c.pushKV("date", TimestampToHRDate(pblockindex->nTime));
1911+
c.pushKV("wallet_version", claim->m_client_version);
1912+
1913+
c.pushKV("total_cpids", (int)superblock.m_cpids.TotalCount());
1914+
c.pushKV("active_beacons", (int)superblock.m_cpids.size());
1915+
c.pushKV("inactive_beacons", (int)superblock.m_cpids.Zeros());
1916+
1917+
c.pushKV("total_magnitude", superblock.m_cpids.TotalMagnitude());
1918+
c.pushKV("average_magnitude", superblock.m_cpids.AverageMagnitude());
1919+
1920+
c.pushKV("total_projects", (int)superblock.m_projects.size());
19161921

1917-
if (const NN::CpidOption cpid_parsed = NN::MiningId::Parse(cpid).TryCpid())
1922+
if (cpid_parsed)
19181923
{
19191924
c.pushKV("Magnitude", superblock.m_cpids.MagnitudeOf(*cpid_parsed));
19201925
}

0 commit comments

Comments
 (0)