aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-03-28 23:51:50 +0100
committerPieter Wuille <pieterw@google.com>2013-04-12 12:17:28 +0200
commit1657c4bc495815febc2137972c3c63b99d2b0189 (patch)
tree57798b51f7014c88f11b1e5bfe11edc123977098 /src/main.h
parent2aa462ec30c3960ae546e4d8d50fdbaffefef718 (diff)
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.
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h14
1 files changed, 7 insertions, 7 deletions
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<CBlockIndex*, CBlockIndexWorkComparator> 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;