Skip to content

Commit

Permalink
Added logging and tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeless committed Dec 1, 2023
1 parent 0979561 commit d1152c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion poller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (p *Poller) Run(ctx context.Context) error {
}
p.logger.Info("retrieved finalized and head block",
zap.Stringer("finalized_block", finalizedBlk),
zap.Stringer("head_block", p.headBlock),
zap.Stringer("chain_head_block", p.headBlock),
)

return bp.Run(ctx, p.startBlockNum, finalizedBlk)
Expand Down Expand Up @@ -141,11 +141,14 @@ func (p *Poller) Fetch(_ context.Context, blkNum uint64) (*pbbstream.Block, erro
}

p.logger.Debug("fetching block", zap.Uint64("block_num", blkNum))
t0 := time.Now()
blkHash, err := p.rpcClient.GetBlockHash(int64(blkNum))
if err != nil {
return nil, fmt.Errorf("unable to get block hash for block %d: %w", blkNum, err)
}
duration := time.Since(t0)

t1 := time.Now()
rpcBlk, err := p.rpcClient.GetBlockVerboseTx(blkHash)
if err != nil {
return nil, fmt.Errorf("unable to get block %d (%s): %w", blkNum, blkHash.String(), err)
Expand All @@ -155,6 +158,9 @@ func (p *Poller) Fetch(_ context.Context, blkNum uint64) (*pbbstream.Block, erro
zap.Int64("block_num", rpcBlk.Height),
zap.String("block_hash", rpcBlk.Hash),
zap.String("prev_hash", rpcBlk.PreviousHash),
zap.Duration("blockhash_duration", duration),
zap.Duration("block_duration", time.Since(t1)),
zap.Duration("total_duration", time.Since(t0)),
)

blk := &pbbitcoin.Block{
Expand Down

0 comments on commit d1152c7

Please sign in to comment.