Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
992bff72
Commit
992bff72
authored
Nov 21, 2023
by
EvanJRichard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't discard the err in client.BlockByNumber, and also, check ctx.Done.
parent
5de8206d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
wait.go
op-e2e/e2eutils/geth/wait.go
+15
-5
No files found.
op-e2e/e2eutils/geth/wait.go
View file @
992bff72
...
...
@@ -99,6 +99,8 @@ func WaitForBlock(number *big.Int, client *ethclient.Client, timeout time.Durati
}
case
err
:=
<-
headSub
.
Err
()
:
return
nil
,
fmt
.
Errorf
(
"error in head subscription: %w"
,
err
)
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
}
...
...
@@ -122,14 +124,22 @@ func waitForBlockTag(number *big.Int, client *ethclient.Client, timeout time.Dur
tagBigInt
:=
big
.
NewInt
(
tag
.
Int64
())
// Use a loop to periodically check the block number.
for
range
ticker
.
C
{
block
,
_
:=
client
.
BlockByNumber
(
ctx
,
tagBigInt
)
if
block
!=
nil
&&
block
.
NumberU64
()
>=
number
.
Uint64
()
{
block
,
err
:=
client
.
BlockByNumber
(
ctx
,
tagBigInt
)
if
err
!=
nil
{
return
nil
,
err
}
if
block
.
NumberU64
()
>=
number
.
Uint64
()
{
return
client
.
BlockByNumber
(
ctx
,
number
)
}
select
{
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
default
:
// Continue polling
}
}
// Context deadline exceeded or some other error.
return
nil
,
ctx
.
Err
()
return
nil
,
ctx
.
Err
()
// In case the loop somehow exits without meeting the condition
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment