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
224b04c0
Unverified
Commit
224b04c0
authored
Jun 24, 2021
by
Matt Masurka
Committed by
GitHub
Jun 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds delay to watcher (#1159)
* Adds delay to watcher * Simplifies delay * Adds changeset
parent
e6e85a62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
big-brooms-melt.md
.changeset/big-brooms-melt.md
+5
-0
watcher.ts
packages/core-utils/src/watcher.ts
+9
-0
No files found.
.changeset/big-brooms-melt.md
0 → 100644
View file @
224b04c0
---
'
@eth-optimism/core-utils'
:
patch
---
Adds a pollInterval delay to watcher.ts
packages/core-utils/src/watcher.ts
View file @
224b04c0
...
@@ -10,16 +10,21 @@ export interface Layer {
...
@@ -10,16 +10,21 @@ export interface Layer {
export
interface
WatcherOptions
{
export
interface
WatcherOptions
{
l1
:
Layer
l1
:
Layer
l2
:
Layer
l2
:
Layer
pollInterval
?:
number
}
}
export
class
Watcher
{
export
class
Watcher
{
public
l1
:
Layer
public
l1
:
Layer
public
l2
:
Layer
public
l2
:
Layer
public
pollInterval
:
number
=
3000
public
NUM_BLOCKS_TO_FETCH
:
number
=
10
_000_000
public
NUM_BLOCKS_TO_FETCH
:
number
=
10
_000_000
constructor
(
opts
:
WatcherOptions
)
{
constructor
(
opts
:
WatcherOptions
)
{
this
.
l1
=
opts
.
l1
this
.
l1
=
opts
.
l1
this
.
l2
=
opts
.
l2
this
.
l2
=
opts
.
l2
if
(
opts
.
pollInterval
)
{
this
.
pollInterval
=
opts
.
pollInterval
}
}
}
public
async
getMessageHashesFromL1Tx
(
l1TxHash
:
string
):
Promise
<
string
[]
>
{
public
async
getMessageHashesFromL1Tx
(
l1TxHash
:
string
):
Promise
<
string
[]
>
{
...
@@ -93,10 +98,14 @@ export class Watcher {
...
@@ -93,10 +98,14 @@ export class Watcher {
const
failureLogs
=
await
layer
.
provider
.
getLogs
(
failureFilter
)
const
failureLogs
=
await
layer
.
provider
.
getLogs
(
failureFilter
)
const
logs
=
successLogs
.
concat
(
failureLogs
)
const
logs
=
successLogs
.
concat
(
failureLogs
)
matches
=
logs
.
filter
((
log
:
ethers
.
providers
.
Log
)
=>
log
.
data
===
msgHash
)
matches
=
logs
.
filter
((
log
:
ethers
.
providers
.
Log
)
=>
log
.
data
===
msgHash
)
// exit loop after first iteration if not polling
// exit loop after first iteration if not polling
if
(
!
pollForPending
)
{
if
(
!
pollForPending
)
{
break
break
}
}
// pause awhile before trying again
await
new
Promise
(
r
=>
setTimeout
(
r
,
this
.
pollInterval
))
}
}
// Message was relayed in the past
// Message was relayed in the past
...
...
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