Commit 7901cccb authored by EvanJRichard's avatar EvanJRichard

Use the ticker in a way that obeys the linter but also doesn't necessarily...

Use the ticker in a way that obeys the linter but also doesn't necessarily block like the previous impl.
parent 992bff72
...@@ -124,22 +124,18 @@ func waitForBlockTag(number *big.Int, client *ethclient.Client, timeout time.Dur ...@@ -124,22 +124,18 @@ func waitForBlockTag(number *big.Int, client *ethclient.Client, timeout time.Dur
tagBigInt := big.NewInt(tag.Int64()) tagBigInt := big.NewInt(tag.Int64())
for range ticker.C { for {
block, err := client.BlockByNumber(ctx, tagBigInt)
if err != nil {
return nil, err
}
if block.NumberU64() >= number.Uint64() {
return client.BlockByNumber(ctx, number)
}
select { select {
case <-ticker.C:
block, err := client.BlockByNumber(ctx, tagBigInt)
if err != nil {
return nil, err
}
if block != nil && block.NumberU64() >= number.Uint64() {
return client.BlockByNumber(ctx, number)
}
case <-ctx.Done(): case <-ctx.Done():
return nil, ctx.Err() return nil, ctx.Err()
default:
// Continue polling
} }
} }
return nil, ctx.Err() // In case the loop somehow exits without meeting the condition
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment