Skip to content

Commit 12eb05d

Browse files
committed
move-only: Move CBlockIndexWorkComparator to blockstorage
...it's declared in blockstorage.h
1 parent c600ee3 commit 12eb05d

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/node/blockstorage.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ bool fHavePruned = false;
2828
bool fPruneMode = false;
2929
uint64_t nPruneTarget = 0;
3030

31+
bool CBlockIndexWorkComparator::operator()(const CBlockIndex* pa, const CBlockIndex* pb) const
32+
{
33+
// First sort by most total work, ...
34+
if (pa->nChainWork > pb->nChainWork) return false;
35+
if (pa->nChainWork < pb->nChainWork) return true;
36+
37+
// ... then by earliest time received, ...
38+
if (pa->nSequenceId < pb->nSequenceId) return false;
39+
if (pa->nSequenceId > pb->nSequenceId) return true;
40+
41+
// Use pointer address as tie breaker (should only happen with blocks
42+
// loaded from disk, as those all have id 0).
43+
if (pa < pb) return false;
44+
if (pa > pb) return true;
45+
46+
// Identical blocks.
47+
return false;
48+
}
49+
3150
static FILE* OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false);
3251
static FlatFileSeq BlockFileSeq();
3352
static FlatFileSeq UndoFileSeq();

src/validation.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,6 @@ const std::vector<std::string> CHECKLEVEL_DOC {
107107
"each level includes the checks of the previous levels",
108108
};
109109

110-
bool CBlockIndexWorkComparator::operator()(const CBlockIndex *pa, const CBlockIndex *pb) const {
111-
// First sort by most total work, ...
112-
if (pa->nChainWork > pb->nChainWork) return false;
113-
if (pa->nChainWork < pb->nChainWork) return true;
114-
115-
// ... then by earliest time received, ...
116-
if (pa->nSequenceId < pb->nSequenceId) return false;
117-
if (pa->nSequenceId > pb->nSequenceId) return true;
118-
119-
// Use pointer address as tie breaker (should only happen with blocks
120-
// loaded from disk, as those all have id 0).
121-
if (pa < pb) return false;
122-
if (pa > pb) return true;
123-
124-
// Identical blocks.
125-
return false;
126-
}
127-
128110
/**
129111
* Mutex to guard access to validation specific variables, such as reading
130112
* or changing the chainstate.

0 commit comments

Comments
 (0)