aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-02-23 12:41:26 -0500
committerGavin Andresen <gavinandresen@gmail.com>2012-02-23 12:41:26 -0500
commitfc4f4c2e9a0f90a2fad9279f755d08b99b27796b (patch)
treeec7beaa3674c9bf047aa34c4bcd2bc7103d69bc8
parent35b327a52087033086803f3b361bf435a66a869b (diff)
parent34f878891520927206fb81993579cfad8e74a793 (diff)
Merge branch 'getblock_cleanup' of https://github.com/luke-jr/bitcoin
-rw-r--r--src/bitcoinrpc.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index be40e937b8..c677b174ca 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -120,6 +120,17 @@ Value ValueFromAmount(int64 amount)
return (double)amount / (double)COIN;
}
+std::string
+HexBits(unsigned int nBits)
+{
+ union {
+ int32_t nBits;
+ char cBits[4];
+ } uBits;
+ uBits.nBits = htonl((int32_t)nBits);
+ return HexStr(BEGIN(uBits.cBits), END(uBits.cBits));
+}
+
void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
{
int confirms = wtx.GetDepthInMainChain();
@@ -147,11 +158,13 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
- result.push_back(Pair("blockcount", blockindex->nHeight));
+ result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK)));
+ result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime()));
result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce));
+ result.push_back(Pair("bits", HexBits(block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
Array txhashes;
BOOST_FOREACH (const CTransaction&tx, block.vtx)
@@ -159,9 +172,9 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
result.push_back(Pair("tx", txhashes));
if (blockindex->pprev)
- result.push_back(Pair("hashprevious", blockindex->pprev->GetBlockHash().GetHex()));
+ result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
if (blockindex->pnext)
- result.push_back(Pair("hashnext", blockindex->pnext->GetBlockHash().GetHex()));
+ result.push_back(Pair("nextblockhash", blockindex->pnext->GetBlockHash().GetHex()));
return result;
}
@@ -1939,13 +1952,7 @@ Value getmemorypool(const Array& params, bool fHelp)
result.push_back(Pair("time", (int64_t)pblock->nTime));
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));
result.push_back(Pair("curtime", (int64_t)GetAdjustedTime()));
-
- union {
- int32_t nBits;
- char cBits[4];
- } uBits;
- uBits.nBits = htonl((int32_t)pblock->nBits);
- result.push_back(Pair("bits", HexStr(BEGIN(uBits.cBits), END(uBits.cBits))));
+ result.push_back(Pair("bits", HexBits(pblock->nBits)));
return result;
}