Skip to content

Commit

Permalink
Move the responsibility of waiting between block fetch to the block f…
Browse files Browse the repository at this point in the history
…etcher ... It will be easier to throttle the block flow from the fetcher since rate limit and API restriction will vary depending on the chain and service provider ...
  • Loading branch information
billettc committed Nov 27, 2023
1 parent e9da1f7 commit b2cf970
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 6 deletions.
2 changes: 0 additions & 2 deletions blockpoller/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package blockpoller

import (
"context"
"time"

pbbstream "github.com/streamingfast/bstream/pb/sf/bstream/v1"
)

type BlockFetcher interface {
PollingInterval() time.Duration
Fetch(ctx context.Context, blkNum uint64) (*pbbstream.Block, error)
}
4 changes: 0 additions & 4 deletions blockpoller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package blockpoller
import (
"context"
"fmt"
"time"

"github.com/streamingfast/bstream"
"github.com/streamingfast/bstream/forkable"
Expand Down Expand Up @@ -85,7 +84,6 @@ func (p *BlockPoller) run(resolvedStartBlock bstream.BlockRef) (err error) {

currentCursor := &cursor{state: ContinuousSegState, logger: p.logger}
blkIter := resolvedStartBlock.Num()
intervalDuration := p.blockFetcher.PollingInterval()
for {
if p.IsTerminating() {
p.logger.Info("block poller is terminating")
Expand All @@ -99,8 +97,6 @@ func (p *BlockPoller) run(resolvedStartBlock bstream.BlockRef) (err error) {
if p.IsTerminating() {
p.logger.Info("block poller is terminating")
}

time.Sleep(intervalDuration)
}
}

Expand Down

0 comments on commit b2cf970

Please sign in to comment.