Skip to content

Commit

Permalink
Code review rework
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley committed Mar 15, 2024
1 parent cb0f99a commit 8cf26de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 0 additions & 6 deletions node/pkg/watchers/evm/blocks_by_timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,3 @@ func (lhs Block) Cmp(rhs Block) int {

return 0
}

func (bts *BlocksByTimestamp) GetStats() (int, Block, Block) {
bts.mutex.Lock()
defer bts.mutex.Unlock()
return len(bts.cache), bts.cache[0], bts.cache[len(bts.cache)-1]
}
5 changes: 3 additions & 2 deletions node/pkg/watchers/evm/ccq_backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

const CCQ_MAX_BATCH_SIZE = int64(1000)
const CCQ_TIMESTAMP_RANGE_IN_SECONDS = uint64(30 * 60)
const CCQ_BACKFILL_DELAY = 100 * time.Millisecond

type (
// ccqBackfillRequest represents a request to backfill the cache. It is the payload on the request channel.
Expand Down Expand Up @@ -78,14 +79,14 @@ func (w *Watcher) ccqBackfillInit(ctx context.Context) error {
if err != nil {
return fmt.Errorf("failed to look up latest block: %w", err)
}
latestBlockNum := int64(latestBlock.Number.Uint64())
latestBlockNum := latestBlock.Number.Int64()
w.ccqLogger.Info("looked up latest block", zap.Int64("latestBlockNum", latestBlockNum), zap.Uint64("timestamp", latestBlock.Time))

var blocks Blocks
if w.ccqBatchSize == 0 {
// Determine the max supported batch size and get the first batch which will start with the latest block and go backwards.
var err error
w.ccqBatchSize, blocks, err = ccqBackFillDetermineMaxBatchSize(ctx, w.ccqLogger, w.ethConn, latestBlockNum, 100*time.Millisecond)
w.ccqBatchSize, blocks, err = ccqBackFillDetermineMaxBatchSize(ctx, w.ccqLogger, w.ethConn, latestBlockNum, CCQ_BACKFILL_DELAY)
if err != nil {
return fmt.Errorf("failed to determine max batch size: %w", err)
}
Expand Down

0 comments on commit 8cf26de

Please sign in to comment.