MCPcopy Create free account
hub / github.com/LUX-Core/lux / CBlockIndexWorkComparator

Class CBlockIndexWorkComparator

src/main.cpp:185–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183namespace
184{
185struct CBlockIndexWorkComparator {
186 bool operator()(CBlockIndex* pa, CBlockIndex* pb) const
187 {
188 // First sort by most total work, ...
189 if (pa->nChainWork > pb->nChainWork) return false;
190 if (pa->nChainWork < pb->nChainWork) return true;
191
192 // ... then by earliest time received, ...
193 if (pa->nSequenceId < pb->nSequenceId) return false;
194 if (pa->nSequenceId > pb->nSequenceId) return true;
195
196 // Use pointer address as tie breaker (should only happen with blocks
197 // loaded from disk, as those all have id 0).
198 if (pa < pb) return false;
199 if (pa > pb) return true;
200
201 // Identical blocks.
202 return false;
203 }
204};
205
206CBlockIndex* pindexBestInvalid;
207

Callers 2

LoadBlockIndexDBFunction · 0.85
CheckBlockIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected