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

Class CBlockIndexWorkComparator

src/validation.cpp:61–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 */
60namespace {
61 struct CBlockIndexWorkComparator
62 {
63 bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const {
64 // First sort by most total work, ...
65 if (pa->nChainWork > pb->nChainWork) return false;
66 if (pa->nChainWork < pb->nChainWork) return true;
67
68 // ... then by earliest time received, ...
69 if (pa->nSequenceId < pb->nSequenceId) return false;
70 if (pa->nSequenceId > pb->nSequenceId) return true;
71
72 // Use pointer address as tie breaker (should only happen with blocks
73 // loaded from disk, as those all have id 0).
74 if (pa < pb) return false;
75 if (pa > pb) return true;
76
77 // Identical blocks.
78 return false;
79 }
80 };
81} // anon namespace
82
83enum DisconnectResult

Callers 3

ActivateBestChainMethod · 0.85
LoadBlockIndexMethod · 0.85
CheckBlockIndexMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected