Clean issues which some LLVM configurations don't like
[novacoin.git] / src / rpcblockchain.cpp
index d8860d5..cb6991e 100644 (file)
@@ -89,6 +89,9 @@ double GetPoSKernelPS()
         pindex = pindex->pprev;
     }
 
+    if (!nStakesHandled)
+        return 0;
+
     return dStakeKernelsTriedAvg / nStakesTime;
 }
 
@@ -118,19 +121,18 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
     result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": "")));
     result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex()));
     result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit()));
-    result.push_back(Pair("modifier", strprintf("%016"PRI64x, blockindex->nStakeModifier)));
+    result.push_back(Pair("modifier", strprintf("%016" PRI64x, blockindex->nStakeModifier)));
     result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum)));
     Array txinfo;
     BOOST_FOREACH (const CTransaction& tx, block.vtx)
     {
         if (fPrintTransactionDetail)
         {
-            Object entry;
-
-            entry.push_back(Pair("txid", tx.GetHash().GetHex()));
-            TxToJSON(tx, 0, entry);
+            CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
+            ssTx << tx;
+            string strHex = HexStr(ssTx.begin(), ssTx.end());
 
-            txinfo.push_back(entry);
+            txinfo.push_back(strHex);
         }
         else
             txinfo.push_back(tx.GetHash().GetHex());
@@ -271,7 +273,7 @@ Value getblockbynumber(const Array& params, bool fHelp)
     return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false);
 }
 
-// ppcoin: get information of sync-checkpoint
+// get information of sync-checkpoint
 Value getcheckpoint(const Array& params, bool fHelp)
 {
     if (fHelp || params.size() != 0)
@@ -287,6 +289,27 @@ Value getcheckpoint(const Array& params, bool fHelp)
     result.push_back(Pair("height", pindexCheckpoint->nHeight));
     result.push_back(Pair("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str()));
 
+    if (Checkpoints::checkpointMessage.vchSig.size() != 0)
+    {
+        Object msgdata;
+        CUnsignedSyncCheckpoint checkpoint;
+
+        CDataStream sMsg(Checkpoints::checkpointMessage.vchMsg, SER_NETWORK, PROTOCOL_VERSION);
+        sMsg >> checkpoint;
+
+        Object parsed; // message version and data (block hash)
+        parsed.push_back(Pair("version", checkpoint.nVersion));
+        parsed.push_back(Pair("hash", checkpoint.hashCheckpoint.GetHex().c_str()));
+        msgdata.push_back(Pair("parsed", parsed));
+
+        Object raw; // raw checkpoint message data
+        raw.push_back(Pair("data", HexStr(Checkpoints::checkpointMessage.vchMsg).c_str()));
+        raw.push_back(Pair("signature", HexStr(Checkpoints::checkpointMessage.vchSig).c_str()));
+        msgdata.push_back(Pair("raw", raw));
+
+        result.push_back(Pair("data", msgdata));
+    }
+
     // Check that the block satisfies synchronized checkpoint
     if (CheckpointsMode == Checkpoints::STRICT)
         result.push_back(Pair("policy", "strict"));