@@ -230,9 +230,9 @@ func (p *Poller) Request(ctx context.Context, blockNumbers []*big.Int) []common.
230230 return nil
231231 }
232232
233- p .lastPolledBlockMutex .Lock ()
233+ p .lastRequestedBlockMutex .Lock ()
234234 p .lastRequestedBlock = new (big.Int ).Set (highestBlockNumber )
235- p .lastPolledBlockMutex .Unlock ()
235+ p .lastRequestedBlockMutex .Unlock ()
236236 return blockData
237237}
238238
@@ -292,14 +292,14 @@ func (p *Poller) reachedPollLimit(blockNumber *big.Int) bool {
292292}
293293
294294func (p * Poller ) getNextBlockRange (ctx context.Context ) ([]* big.Int , error ) {
295- p .blockRangeMutex .Lock ()
296- defer p .blockRangeMutex .Unlock ()
297-
298295 latestBlock , err := p .rpc .GetLatestBlockNumber (ctx )
299296 if err != nil {
300297 return nil , err
301298 }
302299
300+ p .blockRangeMutex .Lock ()
301+ defer p .blockRangeMutex .Unlock ()
302+
303303 p .lastPendingFetchBlockMutex .Lock ()
304304 lastPendingFetchBlock := new (big.Int ).Set (p .lastPendingFetchBlock )
305305 p .lastPendingFetchBlockMutex .Unlock ()
@@ -323,16 +323,16 @@ func (p *Poller) getNextBlockRange(ctx context.Context) ([]*big.Int, error) {
323323 return nil , nil
324324 }
325325
326+ p .lastPendingFetchBlockMutex .Lock ()
327+ p .lastPendingFetchBlock = new (big.Int ).Set (endBlock )
328+ p .lastPendingFetchBlockMutex .Unlock ()
329+
326330 log .Debug ().
327331 Str ("last_pending_block" , lastPendingFetchBlock .String ()).
328332 Str ("last_polled_block" , lastPolledBlock .String ()).
329333 Str ("last_requested_block" , lastRequestedBlock .String ()).
330334 Msgf ("GetNextBlockRange for poller workers" )
331335
332- p .lastPendingFetchBlockMutex .Lock ()
333- p .lastPendingFetchBlock = new (big.Int ).Set (endBlock )
334- p .lastPendingFetchBlockMutex .Unlock ()
335-
336336 return p .createBlockNumbersForRange (startBlock , endBlock ), nil
337337}
338338
0 commit comments