Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nft-event
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
duanjinfei
nft-event
Commits
c5c479b2
Commit
c5c479b2
authored
May 31, 2023
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add print log
parent
751ac5c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
sync.go
sync/sync.go
+4
-2
No files found.
sync/sync.go
View file @
c5c479b2
...
@@ -85,9 +85,8 @@ func (p *PullEvent) GetLogs() {
...
@@ -85,9 +85,8 @@ func (p *PullEvent) GetLogs() {
query
.
Addresses
=
p
.
contractList
query
.
Addresses
=
p
.
contractList
for
{
for
{
query
.
FromBlock
=
p
.
lastBlock
query
.
FromBlock
=
p
.
lastBlock
log
.
Info
(
"start fileter start at "
,
p
.
lastBlock
.
Text
(
10
))
height
,
err
:=
p
.
client
.
BlockNumber
(
p
.
ctx
)
height
,
err
:=
p
.
client
.
BlockNumber
(
p
.
ctx
)
log
.
Info
(
"
c
urrent node height:"
,
height
)
log
.
Info
(
"
C
urrent node height:"
,
height
)
if
height
<
p
.
lastBlock
.
Uint64
()
{
if
height
<
p
.
lastBlock
.
Uint64
()
{
time
.
Sleep
(
time
.
Second
)
time
.
Sleep
(
time
.
Second
)
continue
continue
...
@@ -101,13 +100,16 @@ func (p *PullEvent) GetLogs() {
...
@@ -101,13 +100,16 @@ func (p *PullEvent) GetLogs() {
query
.
FromBlock
=
new
(
big
.
Int
)
.
Sub
(
p
.
lastBlock
,
big
.
NewInt
(
backBlock
))
query
.
FromBlock
=
new
(
big
.
Int
)
.
Sub
(
p
.
lastBlock
,
big
.
NewInt
(
backBlock
))
query
.
ToBlock
=
p
.
lastBlock
query
.
ToBlock
=
p
.
lastBlock
}
}
log
.
Infof
(
"start filter bloct at:%s, end filter block at:%s"
,
query
.
FromBlock
.
Text
(
10
),
query
.
ToBlock
.
Text
(
10
))
allLogs
,
err
:=
p
.
client
.
FilterLogs
(
p
.
ctx
,
query
)
allLogs
,
err
:=
p
.
client
.
FilterLogs
(
p
.
ctx
,
query
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"filter logs failed"
,
err
)
log
.
Error
(
"filter logs failed"
,
err
)
continue
continue
}
}
log
.
Info
(
"Filter log length:"
,
len
(
allLogs
))
if
len
(
allLogs
)
>
0
{
if
len
(
allLogs
)
>
0
{
for
_
,
vlog
:=
range
allLogs
{
for
_
,
vlog
:=
range
allLogs
{
log
.
Info
(
"Logs to be processed:"
,
vlog
)
handle
,
exist
:=
p
.
contractHandler
[
vlog
.
Address
]
handle
,
exist
:=
p
.
contractHandler
[
vlog
.
Address
]
if
exist
{
if
exist
{
handle
(
vlog
)
handle
(
vlog
)
...
...
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