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
c458f7a5
Unverified
Commit
c458f7a5
authored
Aug 25, 2021
by
t11s
Committed by
GitHub
Aug 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Watcher: Make blocks to fetch a config option
parent
9c99393f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
watcher.ts
packages/core-utils/src/watcher.ts
+6
-2
No files found.
packages/core-utils/src/watcher.ts
View file @
c458f7a5
...
...
@@ -11,13 +11,14 @@ export interface WatcherOptions {
l1
:
Layer
l2
:
Layer
pollInterval
?:
number
blocksToFetch
?:
number
}
export
class
Watcher
{
public
l1
:
Layer
public
l2
:
Layer
public
pollInterval
=
3000
public
NUM_BLOCKS_TO_FETCH
=
9
_999
public
blocksToFetch
=
2000
constructor
(
opts
:
WatcherOptions
)
{
this
.
l1
=
opts
.
l1
...
...
@@ -25,6 +26,9 @@ export class Watcher {
if
(
opts
.
pollInterval
)
{
this
.
pollInterval
=
opts
.
pollInterval
}
if
(
opts
.
blocksToFetch
)
{
this
.
blocksToFetch
=
opts
.
blocksToFetch
}
}
public
async
getMessageHashesFromL1Tx
(
l1TxHash
:
string
):
Promise
<
string
[]
>
{
...
...
@@ -83,7 +87,7 @@ export class Watcher {
// scan for transaction with specified message
while
(
matches
.
length
===
0
)
{
const
blockNumber
=
await
layer
.
provider
.
getBlockNumber
()
const
startingBlock
=
Math
.
max
(
blockNumber
-
this
.
NUM_BLOCKS_TO_FETCH
,
0
)
const
startingBlock
=
Math
.
max
(
blockNumber
-
this
.
blocksToFetch
,
0
)
const
successFilter
:
ethers
.
providers
.
Filter
=
{
address
:
layer
.
messengerAddress
,
topics
:
[
ethers
.
utils
.
id
(
`RelayedMessage(bytes32)`
)],
...
...
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