mirror of
https://github.com/alexgo-io/gaze-indexer.git
synced 2026-04-29 20:25:24 +08:00
chore: add performance logger for debyug
Co-authored-by: Gaze <dev@gaze.network>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/rpcclient"
|
||||
@@ -155,6 +156,16 @@ func (d *BitcoinNodeDatasource) FetchAsync(ctx context.Context, from, to int64,
|
||||
return
|
||||
default:
|
||||
stream.Go(func() []*types.Block {
|
||||
startAt := time.Now()
|
||||
defer func() {
|
||||
logger.DebugContext(ctx, "[BitcoinNodeDatasource] Fetched blocks",
|
||||
slogx.Int("total_blocks", len(chunk)),
|
||||
slogx.Int64("from", chunk[0]),
|
||||
slogx.Int64("to", chunk[len(chunk)-1]),
|
||||
slogx.Stringer("duration", time.Since(startAt)),
|
||||
slogx.Int64("duration_ms", time.Since(startAt).Milliseconds()),
|
||||
)
|
||||
}()
|
||||
// TODO: should concurrent fetch block or not ?
|
||||
blocks := make([]*types.Block, 0, len(chunk))
|
||||
for _, height := range chunk {
|
||||
|
||||
Reference in New Issue
Block a user