Skip to content

Commit 2a2bc0b

Browse files
committed
Add custom height check back
This was dropped while dealing with merge conflict in "implement index parallel sync".
1 parent c595228 commit 2a2bc0b

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
@@ -264,6 +264,13 @@ void BaseIndex::Sync()
264264
return;
265265
}
266266

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

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

0 commit comments

Comments
 (0)