Skip to content

Commit bdabb00

Browse files
Check block height before populating BlockCache
1 parent 4b531f7 commit bdabb00

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

block/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ func (m *Manager) SyncLoop(ctx context.Context, cancel context.CancelFunc) {
305305
case <-blockTicker.C:
306306
m.sendNonBlockingSignalToBlockStoreCh()
307307
case blockEvent := <-m.blockInCh:
308+
// Only validated blocks are sent to blockInCh, so we can safely assume that blockEvent.block is valid
308309
block := blockEvent.block
309310
daHeight := blockEvent.daHeight
310311
blockHash := block.Hash().String()
@@ -314,7 +315,7 @@ func (m *Manager) SyncLoop(ctx context.Context, cancel context.CancelFunc) {
314315
"daHeight", daHeight,
315316
"hash", blockHash,
316317
)
317-
if m.blockCache.isSeen(blockHash) {
318+
if m.blockCache.isSeen(blockHash) || blockHeight <= m.store.Height() {
318319
m.logger.Debug("block already seen", "height", blockHeight, "block hash", blockHash)
319320
continue
320321
}

0 commit comments

Comments
 (0)