Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(log): ensure node attribute on node logging #69

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/rpc/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ func (n *Node) ChainID() string {
}

func (n *Node) Start(ctx context.Context) error {
log := log.With().Str("node", n.Redacted()).Logger()

// Wait for the node to be ready
initTicker := time.NewTicker(30 * time.Second)
for {
Expand Down Expand Up @@ -167,25 +169,25 @@ func (n *Node) Start(ctx context.Context) error {
for {
select {
case <-ctx.Done():
log.Debug().Err(ctx.Err()).Str("node", n.Redacted()).Msgf("stopping node status loop")
log.Debug().Err(ctx.Err()).Msgf("stopping node status loop")
return nil

case evt := <-blocksEvents:
log.Debug().Str("node", n.Redacted()).Msg("got new block event")
log.Debug().Msg("got new block event")
n.saveLatestBlock(evt.Data.(types.EventDataNewBlock).Block)
n.handleEvent(ctx, EventNewBlock, &evt)
blocksTicker.Reset(10 * time.Second)

case evt := <-validatorEvents:
log.Debug().Str("node", n.Redacted()).Msg("got validator set update event")
log.Debug().Msg("got validator set update event")
n.handleEvent(ctx, EventValidatorSetUpdates, &evt)

case <-blocksTicker.C:
log.Debug().Str("node", n.Redacted()).Msg("syncing latest blocks")
log.Debug().Msg("syncing latest blocks")
n.syncBlocks(ctx)

case <-statusTicker.C:
log.Debug().Str("node", n.Redacted()).Msg("syncing status")
log.Debug().Msg("syncing status")
n.syncStatus(ctx)
}
}
Expand Down
Loading