Skip to content

Commit

Permalink
fix: handle events only when event handlers are registered (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
hallazzang authored Oct 16, 2024
1 parent 86916b3 commit 3e945e2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions node/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ func (n *Node) handleNewBlock(ctx context.Context, block *rpccoretypes.ResultBlo
}
}

for eventIndex, event := range blockResult.FinalizeBlockEvents {
err := n.handleEvent(ctx, block.Block.Height, block.Block.Time, latestChainHeight, event)
if err != nil {
return fmt.Errorf("failed to handle event: finalize block, event_index: %d; %w", eventIndex, err)
if len(n.eventHandlers) != 0 {
for eventIndex, event := range blockResult.FinalizeBlockEvents {
err := n.handleEvent(ctx, block.Block.Height, block.Block.Time, latestChainHeight, event)
if err != nil {
return fmt.Errorf("failed to handle event: finalize block, event_index: %d; %w", eventIndex, err)
}
}
}

Expand Down

0 comments on commit 3e945e2

Please sign in to comment.