Skip to content

Commit 1a07e49

Browse files
Ruteriavalonche
authored andcommitted
Adjust block number for bundle fetching (ethereum#32)
1 parent 75edca8 commit 1a07e49

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

flashbotsextra/fetcher.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func (b *bundleFetcher) Run() {
4444
eventCh := make(chan core.ChainHeadEvent)
4545
b.backend.BlockChain().SubscribeChainHeadEvent(eventCh)
4646
pushBlockNum := func() {
47-
for blockNum := range eventCh {
48-
b.blockNumCh <- blockNum.Block.Header().Number.Int64()
47+
for currentBlockNum := range eventCh {
48+
b.blockNumCh <- currentBlockNum.Block.Header().Number.Int64()
4949
}
5050
}
5151
addMevBundle := func() {
@@ -75,37 +75,37 @@ func (b *bundleFetcher) Run() {
7575
}
7676

7777
func (b *bundleFetcher) fetchAndPush(ctx context.Context, pushMevBundles func(bundles []DbBundle)) {
78-
var blockNum int64
78+
var currentBlockNum int64
7979
lowPrioBundleTicker := time.NewTicker(time.Second * 2)
8080
defer lowPrioBundleTicker.Stop()
8181

8282
for {
8383
select {
84-
case blockNum = <-b.blockNumCh:
84+
case currentBlockNum = <-b.blockNumCh:
8585
ctxH, cancelH := context.WithTimeout(ctx, time.Second*3)
86-
bundles, err := b.db.GetPriorityBundles(ctxH, blockNum, true)
86+
bundles, err := b.db.GetPriorityBundles(ctxH, currentBlockNum+1, true)
8787
cancelH()
8888
if err != nil {
8989
log.Error("failed to fetch high prio bundles", "err", err)
9090
continue
9191
}
92-
log.Info("Fetching High prio bundles", "size", len(bundles), "blockNum", blockNum)
92+
log.Info("Fetching High prio bundles", "size", len(bundles), "currentlyBuiltBlockNum", currentBlockNum+1)
9393
if len(bundles) != 0 {
9494
pushMevBundles(bundles)
9595
}
9696

9797
case <-lowPrioBundleTicker.C:
98-
if blockNum == 0 {
98+
if currentBlockNum == 0 {
9999
continue
100100
}
101101
ctxL, cancelL := context.WithTimeout(ctx, time.Second*3)
102-
bundles, err := b.db.GetPriorityBundles(ctxL, blockNum, false)
102+
bundles, err := b.db.GetPriorityBundles(ctxL, currentBlockNum+1, false)
103103
cancelL()
104104
if err != nil {
105105
log.Error("failed to fetch low prio bundles", "err", err)
106106
continue
107107
}
108-
log.Info("Fetching low prio bundles", "len", len(bundles), "blockNum", blockNum)
108+
log.Info("Fetching low prio bundles", "len", len(bundles), "currentlyBuiltBlockNum", currentBlockNum+1)
109109
if len(bundles) != 0 {
110110
pushMevBundles(bundles)
111111
}

0 commit comments

Comments
 (0)