Skip to content

Commit

Permalink
fixed issue with block backfilling for far behind clients
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 23, 2023
1 parent ae550a8 commit da73fb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion indexer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,12 @@ func (client *IndexerClient) ensureParentBlocks(currentBlock *CacheBlock) error
logger.WithField("client", client.clientName).Debugf("received known block %v:%v [0x%x] backfill", utils.EpochOfSlot(parentSlot), parentSlot, parentRoot)
}
client.ensureBlock(parentBlock, parentHead)
if int64(utils.EpochOfSlot(parentSlot)) <= client.lastFinalizedEpoch {

finalizedEpoch := client.indexerCache.finalizedEpoch
if client.lastFinalizedEpoch > finalizedEpoch {
finalizedEpoch = client.lastFinalizedEpoch
}
if int64(utils.EpochOfSlot(parentSlot)) <= finalizedEpoch {
logger.WithField("client", client.clientName).Debugf("backfill cache: reached finalized slot %v:%v [0x%x]", utils.EpochOfSlot(parentSlot), parentSlot, parentRoot)
break
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/beaconstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (bs *BeaconStream) subscribeStream(endpoint string, events uint16) *eventst
url := fmt.Sprintf("%s/eth/v1/events?topics=%v", endpoint, topics.String())
req, err := http.NewRequest("GET", url, nil)
var stream *eventstream.Stream
if err != nil {
if err == nil {
for headerKey, headerVal := range bs.client.headers {
req.Header.Set(headerKey, headerVal)
}
Expand Down

0 comments on commit da73fb1

Please sign in to comment.