Skip to content

Commit

Permalink
send block after applying and send microBlockInv in full mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-Rampage committed May 29, 2024
1 parent 39f0751 commit 4e7d3c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/node/fsm/ng_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (a *NGState) Block(peer peer.Peer, block *proto.Block) (State, Async, error
a.blocksCache.Clear()
a.blocksCache.AddBlockState(block)
a.baseInfo.scheduler.Reschedule()
a.baseInfo.actions.SendBlock(block)
a.baseInfo.actions.SendScore(a.baseInfo.storage)
a.baseInfo.CleanUtx()

Expand Down Expand Up @@ -245,6 +246,13 @@ func (a *NGState) MicroBlock(p peer.Peer, micro *proto.MicroBlock) (State, Async
a.baseInfo.MicroBlockCache.AddMicroBlock(block.BlockID(), micro)
a.blocksCache.AddBlockState(block)
a.baseInfo.scheduler.Reschedule()
// Notify all connected peers about new microblock, send them microblock inv network message
if inv, ok := a.baseInfo.MicroBlockInvCache.Get(block.BlockID()); ok {
//TODO: We have to exclude from recipients peers that already have this microblock
if err = broadcastMicroBlockInv(a.baseInfo, inv); err != nil {
return a, nil, a.Errorf(errors.Wrap(err, "failed to handle microblock message"))
}
}
return a, nil, nil
}
defer func() {
Expand Down
1 change: 1 addition & 0 deletions pkg/node/fsm/wait_snapshot_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (a *WaitSnapshotState) BlockSnapshot(
a.blocksCache.AddBlockState(a.blockWaitingForSnapshot)
a.blocksCache.AddSnapshot(blockID, snapshot)
a.baseInfo.scheduler.Reschedule()
a.baseInfo.actions.SendBlock(a.blockWaitingForSnapshot)
a.baseInfo.actions.SendScore(a.baseInfo.storage)
a.baseInfo.CleanUtx()
return processScoreAfterApplyingOrReturnToNG(a, a.baseInfo, a.receivedScores, a.blocksCache)
Expand Down

0 comments on commit 4e7d3c4

Please sign in to comment.