Skip to content

Commit 7c42695

Browse files
committed
Add custom height check back
This was dropped while dealing with merge conflict in "implement index parallel sync".
1 parent 0e75edb commit 7c42695

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/index/base.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ void BaseIndex::Sync()
263263
return;
264264
}
265265

266+
// If pindex_next is our first block and we are starting from a custom height,
267+
// set pindex to be the previous block. This ensures we test that we can still rewind
268+
// from our custom start height in the event of a reorg.
269+
if (pindex_next->nHeight == m_start_height && m_start_height > 0) {
270+
pindex = pindex_next->pprev;
271+
}
272+
266273
// Handle potential reorgs; if the next block's parent doesn't match our current tip,
267274
// rewind our index state to match the chain and resume from there.
268275
if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {
@@ -414,6 +421,13 @@ void BaseIndex::Sync()
414421
break;
415422
}
416423

424+
// If pindex_next is our first block and we are starting from a custom height,
425+
// set pindex to be the previous block. This ensures we test that we can still rewind
426+
// from our custom start height in the event of a reorg.
427+
if (pindex_next->nHeight == m_start_height && m_start_height > 0) {
428+
pindex = pindex_next->pprev;
429+
}
430+
417431
// New blocks arrived during sync.
418432
// Handle potential reorgs; if the next block's parent doesn't match our tip,
419433
// rewind index state to the correct chain, then resume.

0 commit comments

Comments
 (0)