From 1657c4bc495815febc2137972c3c63b99d2b0189 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 28 Mar 2013 23:51:50 +0100 Subject: Use a uint256 for bnChainWork Every block index entry currently requires a separately-allocated CBigNum. By replacing them with uint256, it's just 32 bytes extra in CBlockIndex itself. This should save us a few megabytes in RAM, and less allocation overhead. --- src/main.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main.h') diff --git a/src/main.h b/src/main.h index 9a3664a437..24b2cb2aa6 100644 --- a/src/main.h +++ b/src/main.h @@ -77,8 +77,8 @@ extern std::set setBlockIndexValid; extern uint256 hashGenesisBlock; extern CBlockIndex* pindexGenesisBlock; extern int nBestHeight; -extern CBigNum bnBestChainWork; -extern CBigNum bnBestInvalidWork; +extern uint256 nBestChainWork; +extern uint256 nBestInvalidWork; extern uint256 hashBestChain; extern CBlockIndex* pindexBest; extern unsigned int nTransactionsUpdated; @@ -1619,7 +1619,7 @@ public: unsigned int nUndoPos; // (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block - CBigNum bnChainWork; + uint256 nChainWork; // Number of transactions in this block. // Note: in a potential headers-first mode, this number cannot be relied upon @@ -1648,7 +1648,7 @@ public: nFile = 0; nDataPos = 0; nUndoPos = 0; - bnChainWork = 0; + nChainWork = 0; nTx = 0; nChainTx = 0; nStatus = 0; @@ -1669,7 +1669,7 @@ public: nFile = 0; nDataPos = 0; nUndoPos = 0; - bnChainWork = 0; + nChainWork = 0; nTx = 0; nChainTx = 0; nStatus = 0; @@ -1793,8 +1793,8 @@ public: struct CBlockIndexWorkComparator { bool operator()(CBlockIndex *pa, CBlockIndex *pb) { - if (pa->bnChainWork > pb->bnChainWork) return false; - if (pa->bnChainWork < pb->bnChainWork) return true; + if (pa->nChainWork > pb->nChainWork) return false; + if (pa->nChainWork < pb->nChainWork) return true; if (pa->GetBlockHash() < pb->GetBlockHash()) return false; if (pa->GetBlockHash() > pb->GetBlockHash()) return true; -- cgit v1.2.3