Skip to content

Commit

Permalink
fix:unable to switch sync mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lochjin committed Dec 6, 2024
1 parent 7032ea9 commit bfc14b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions consensus/model/block_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ type BlockChain interface {
ForeachBlueBlocks(start Block, depth uint, powType pow.PowType, fn func(block Block, header *types.BlockHeader) error) error
GetUtxo(outpoint types.TxOutPoint) (interface{}, error)
VerifyMeerTx(tx Tx) error
IsSnapSyncing() bool
}
3 changes: 3 additions & 0 deletions meerevm/meer/meerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ func (b *MeerChain) OnStateChange(header *types.Header, state *state.StateDB, bo
return
}
if b.block == nil {
if b.consensus.BlockChain().IsSnapSyncing() {
return
}
log.Error("No meer block for state change", "hash", header.Hash().String())
return
}
Expand Down
6 changes: 5 additions & 1 deletion p2p/synch/peersync.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,15 @@ func (ps *PeerSync) handleStallSample() {
if atomic.LoadInt32(&ps.shutdown) != 0 {
return
}
if ps.IsSnapSync() {
return
}
lbid := ps.Chain().BlockDAG().GetLastBlockID()
if ps.lastBlockID != lbid {
ps.lastBlockID = lbid
return
}
ps.lastBlockID = lbid
ps.Chain().MeerChain().Downloader().Progress()
ps.TryAgainUpdateSyncPeer(true)
}

Expand Down

0 comments on commit bfc14b6

Please sign in to comment.