Changeset View
Changeset View
Standalone View
Standalone View
src/blockindexworkcomparator.h
Show All 12 Lines | bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const { | ||||
// First sort by most total work, ... | // First sort by most total work, ... | ||||
if (pa->nChainWork > pb->nChainWork) { | if (pa->nChainWork > pb->nChainWork) { | ||||
return false; | return false; | ||||
} | } | ||||
if (pa->nChainWork < pb->nChainWork) { | if (pa->nChainWork < pb->nChainWork) { | ||||
return true; | return true; | ||||
} | } | ||||
// ... then sort by most honestly mined, ... | |||||
int64_t aTimeDiff = std::llabs(pa->GetReceivedTimeDiff()); | |||||
int64_t bTimeDiff = std::llabs(pb->GetReceivedTimeDiff()); | |||||
if (aTimeDiff < bTimeDiff) { | |||||
return false; | |||||
} | |||||
if (aTimeDiff > bTimeDiff) { | |||||
return true; | |||||
} | |||||
// ... then by earliest time received, ... | // ... then by earliest time received, ... | ||||
if (pa->nSequenceId < pb->nSequenceId) { | if (pa->nSequenceId < pb->nSequenceId) { | ||||
return false; | return false; | ||||
} | } | ||||
if (pa->nSequenceId > pb->nSequenceId) { | if (pa->nSequenceId > pb->nSequenceId) { | ||||
return true; | return true; | ||||
} | } | ||||
Show All 15 Lines |