Skip to content

Commit

Permalink
feat: rework bucketing to minimize requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Jul 2, 2024
1 parent 4c007f9 commit 0febe46
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions oracle/pkg/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,11 @@ func (u *Updater) getL1Txns(ctx context.Context, blockNum uint64) (map[string]Tx
for i, tx := range block.Transactions() {
txnsArray[i] = tx.Hash()
}
const bucketSize = 50 // Arbitrary number for bucket size

bucketSize := (len(txnsArray) + 3) / 4 // Calculate the size of each bucket, rounding up
buckets := make([][]common.Hash, 4)
for i := 0; i < 4; i++ {
numBuckets := (len(txnsArray) + bucketSize - 1) / bucketSize // Calculate the number of buckets needed, rounding up
buckets := make([][]common.Hash, numBuckets)
for i := 0; i < numBuckets; i++ {
start := i * bucketSize
end := start + bucketSize
if end > len(txnsArray) {
Expand Down

0 comments on commit 0febe46

Please sign in to comment.