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
abc7df60
Commit
abc7df60
authored
Jun 13, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(c-mon): Reduce loop time, and return when waiting for new blocks
parent
1904e4ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
+27
-14
service.ts
packages/chain-mon/src/wallet-mon/service.ts
+27
-14
No files found.
packages/chain-mon/src/wallet-mon/service.ts
View file @
abc7df60
...
@@ -77,7 +77,7 @@ export class WalletMonService extends BaseServiceV2<
...
@@ -77,7 +77,7 @@ export class WalletMonService extends BaseServiceV2<
name
:
'
wallet-mon
'
,
name
:
'
wallet-mon
'
,
loop
:
true
,
loop
:
true
,
options
:
{
options
:
{
loopIntervalMs
:
60
_
000
,
loopIntervalMs
:
1
000
,
...
options
,
...
options
,
},
},
optionsSpec
:
{
optionsSpec
:
{
...
@@ -120,6 +120,7 @@ export class WalletMonService extends BaseServiceV2<
...
@@ -120,6 +120,7 @@ export class WalletMonService extends BaseServiceV2<
})
})
this
.
state
.
chainId
=
await
getChainId
(
this
.
options
.
rpc
)
this
.
state
.
chainId
=
await
getChainId
(
this
.
options
.
rpc
)
const
l1StartingBlockTag
=
networks
[
this
.
state
.
chainId
].
l1StartingBlockTag
const
l1StartingBlockTag
=
networks
[
this
.
state
.
chainId
].
l1StartingBlockTag
if
(
this
.
options
.
startBlockNumber
===
-
1
)
{
if
(
this
.
options
.
startBlockNumber
===
-
1
)
{
...
@@ -131,7 +132,14 @@ export class WalletMonService extends BaseServiceV2<
...
@@ -131,7 +132,14 @@ export class WalletMonService extends BaseServiceV2<
}
}
protected
async
main
():
Promise
<
void
>
{
protected
async
main
():
Promise
<
void
>
{
// get the next unchecked block
if
(
(
await
this
.
options
.
rpc
.
getBlockNumber
())
<
this
.
state
.
highestUncheckedBlockNumber
)
{
this
.
logger
.
info
(
'
Waiting for new blocks
'
)
return
}
const
network
=
networks
[
this
.
state
.
chainId
]
const
network
=
networks
[
this
.
state
.
chainId
]
const
accounts
=
network
.
accounts
const
accounts
=
network
.
accounts
...
@@ -142,39 +150,44 @@ export class WalletMonService extends BaseServiceV2<
...
@@ -142,39 +150,44 @@ export class WalletMonService extends BaseServiceV2<
number
:
block
.
number
,
number
:
block
.
number
,
})
})
const
transactions
=
[]
for
(
const
txHash
of
block
.
transactions
)
{
for
(
const
txHash
of
block
.
transactions
)
{
console
.
log
(
'
txHash:
'
,
txHash
)
const
t
=
await
this
.
options
.
rpc
.
getTransaction
(
txHash
)
for
(
const
account
of
accounts
)
{
transactions
.
push
(
t
)
console
.
log
(
'
account:
'
,
account
)
}
const
tx
=
await
this
.
options
.
rpc
.
getTransaction
(
txHash
)
if
(
compareAddrs
(
account
.
wallet
,
tx
.
from
))
{
for
(
const
transaction
of
transactions
)
{
if
(
compareAddrs
(
account
.
target
,
tx
.
to
))
{
for
(
const
account
of
accounts
)
{
if
(
compareAddrs
(
account
.
wallet
,
transaction
.
from
))
{
if
(
compareAddrs
(
account
.
target
,
transaction
.
to
))
{
this
.
metrics
.
validatedCalls
.
inc
({
this
.
metrics
.
validatedCalls
.
inc
({
label
:
account
.
label
,
nickname
:
account
.
label
,
wallet
:
account
.
address
,
wallet
:
account
.
address
,
target
:
account
.
target
,
target
:
account
.
target
,
})
})
this
.
logger
.
info
(
'
validated call
'
,
{
this
.
logger
.
info
(
'
validated call
'
,
{
label
:
account
.
label
,
nickname
:
account
.
label
,
wallet
:
account
.
address
,
wallet
:
account
.
address
,
target
:
account
.
target
,
target
:
account
.
target
,
})
})
}
else
{
}
else
{
this
.
metrics
.
unexpectedCalls
.
inc
({
this
.
metrics
.
unexpectedCalls
.
inc
({
label
:
account
.
label
,
nickname
:
account
.
label
,
wallet
:
account
.
address
,
wallet
:
account
.
address
,
target
:
t
x
.
to
,
target
:
t
ransaction
.
to
,
})
})
this
.
logger
.
error
(
'
Unexpected call detected
'
,
{
this
.
logger
.
error
(
'
Unexpected call detected
'
,
{
label
:
account
.
label
,
nickname
:
account
.
label
,
address
:
account
.
address
,
address
:
account
.
address
,
target
:
t
x
.
to
,
target
:
t
ransaction
.
to
,
})
})
}
}
}
}
}
}
}
}
this
.
logger
.
info
(
'
Checked block
'
,
{
number
:
this
.
state
.
highestUncheckedBlockNumber
,
})
this
.
state
.
highestUncheckedBlockNumber
++
this
.
state
.
highestUncheckedBlockNumber
++
}
}
}
}
...
...
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