| 29 | class CBaseCoinTransferTx; |
| 30 | |
| 31 | Object BlockToJSON(const CBlock& block, const CBlockIndex* pBlockIndex) { |
| 32 | Object result; |
| 33 | result.push_back(Pair("curr_block_hash", block.GetHash().GetHex())); |
| 34 | if (pBlockIndex->pprev) |
| 35 | result.push_back(Pair("prev_block_hash", pBlockIndex->pprev->GetBlockHash().GetHex())); |
| 36 | CBlockIndex* pNext = chainActive.Next(pBlockIndex); |
| 37 | if (pNext) |
| 38 | result.push_back(Pair("next_block_hash", pNext->GetBlockHash().GetHex())); |
| 39 | |
| 40 | result.push_back(Pair("bp_uid", block.vptx[0]->txUid.ToString())); |
| 41 | result.push_back(Pair("version", block.GetVersion())); |
| 42 | result.push_back(Pair("merkle_root", block.GetMerkleRootHash().GetHex())); |
| 43 | result.push_back(Pair("fuel_rate", block.GetFuelRate())); |
| 44 | result.push_back(Pair("total_fuel_fee", block.GetFuelFee())); |
| 45 | result.push_back(Pair("confirmations", (int32_t)chainActive.Height() - pBlockIndex->height + 1)); |
| 46 | result.push_back(Pair("size", (int32_t)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); |
| 47 | result.push_back(Pair("height", (int32_t)block.GetHeight())); |
| 48 | result.push_back(Pair("tx_count", (int32_t)block.vptx.size())); |
| 49 | |
| 50 | Array txs; |
| 51 | for (const auto& ptx : block.vptx) |
| 52 | txs.push_back(ptx->GetHash().GetHex()); |
| 53 | result.push_back(Pair("tx", txs)); |
| 54 | |
| 55 | result.push_back(Pair("time", block.GetBlockTime())); |
| 56 | result.push_back(Pair("nonce", (uint64_t)block.GetNonce())); |
| 57 | |
| 58 | Array prices; |
| 59 | const auto& priceMap = block.GetBlockMedianPrice(); |
| 60 | for (const auto &item : priceMap) { |
| 61 | if (item.second == 0) { |
| 62 | continue; |
| 63 | } |
| 64 | |
| 65 | Object price; |
| 66 | price.push_back(Pair("coin_symbol", item.first.first)); |
| 67 | price.push_back(Pair("price_symbol", item.first.second)); |
| 68 | price.push_back(Pair("price", (double) item.second / PRICE_BOOST)); |
| 69 | prices.push_back(price); |
| 70 | } |
| 71 | result.push_back(Pair("median_price", prices)); |
| 72 | |
| 73 | return result; |
| 74 | } |
| 75 | |
| 76 | Value getblockcount(const Array& params, bool fHelp) { |
| 77 | if (fHelp || params.size() != 0) |
no test coverage detected