Skip to content

Commit

Permalink
Fix: fixed race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoog committed Nov 6, 2023
1 parent 097daf3 commit a3ba09d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/protocol/block_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ func (b *BlockDispatcher) processWarpSyncResponse(commitmentID iotago.Commitment

b.processedWarpSyncRequests.Add(commitmentID)

// make sure the engine is clean before we start processing the blocks
// make sure the engine is clean and requires a warp-sync before we start processing the blocks
if targetEngine.Workers.WaitChildren(); targetEngine.Storage.Settings().LatestCommitment().ID().Slot() > commitmentID.Slot() {
return nil
}
targetEngine.Reset()

// Once all blocks are booked we
Expand Down
3 changes: 1 addition & 2 deletions pkg/protocol/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func New(
func(e *Engine) {
fmt.Println("Engine Settings", e.Storage.Settings().String())
},
(*Engine).Reset,
(*Engine).TriggerInitialized,
)
}
Expand All @@ -223,8 +224,6 @@ func (e *Engine) ProcessBlockFromPeer(block *model.Block, source peer.ID) {

// Reset resets the component to a clean state as if it was created at the last commitment.
func (e *Engine) Reset() {
e.Workers.WaitChildren()

e.BlockRequester.Clear()
e.Storage.Reset()
e.EvictionState.Reset()
Expand Down

0 comments on commit a3ba09d

Please sign in to comment.