MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / CBlockIndexWorkComparator

Class CBlockIndexWorkComparator

src/main.cpp:114–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112namespace {
113
114 struct CBlockIndexWorkComparator
115 {
116 bool operator()(CBlockIndex *pa, CBlockIndex *pb) const {
117 // First sort by most total work, ...
118 if (pa->nChainWork > pb->nChainWork) return false;
119 if (pa->nChainWork < pb->nChainWork) return true;
120
121 // ... then by earliest time received, ...
122 if (pa->nSequenceId < pb->nSequenceId) return false;
123 if (pa->nSequenceId > pb->nSequenceId) return true;
124
125 // Use pointer address as tie breaker (should only happen with blocks
126 // loaded from disk, as those all have id 0).
127 if (pa < pb) return false;
128 if (pa > pb) return true;
129
130 // Identical blocks.
131 return false;
132 }
133 };
134
135 CBlockIndex *pindexBestInvalid;
136

Callers 2

LoadBlockIndexDBFunction · 0.85
CheckBlockIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected