Skip to content

Commit

Permalink
feat(dpos): get block from block cache first
Browse files Browse the repository at this point in the history
  • Loading branch information
RainFallsSilent committed Jan 22, 2025
1 parent d92df7c commit 01563e0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dpos/manager/dposmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ func (d *DPOSManager) OnGetBlock(id dpeer.PID, blockHash common.Uint256) {
if !d.isCurrentArbiter() {
return
}

if block, ok := d.GetBlockCache().TryGetValue(blockHash); ok {
go d.network.SendMessageToPeer(id, msg.NewBlock(block))
return
}

if block, err := d.getBlock(blockHash); err == nil {
go d.network.SendMessageToPeer(id, msg.NewBlock(block))
}
Expand Down

0 comments on commit 01563e0

Please sign in to comment.