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
751ac5c3
Commit
751ac5c3
authored
May 31, 2023
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change node and scan block from、to
parent
15a2b46b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
3 deletions
+14
-3
app.conf
conf/app.conf
+2
-1
Handler.go
sync/Handler.go
+4
-0
sync.go
sync/sync.go
+8
-2
No files found.
conf/app.conf
View file @
751ac5c3
...
...
@@ -2,11 +2,12 @@ appname = nft-event
httpport
=
9000
runmode
=
dev
mysql
=
debian
-
sys
-
maint
:
H4khSGKhjhMJogpE
@
tcp
(
127
.
0
.
0
.
1
:
3306
)/
nftEvent
?
charset
=
utf8
rpcUrl
=
https
://
cloudflare
-
eth
.
com
rpcUrl
=
https
://
eth
-
mainnet
.
g
.
alchemy
.
com
/
v2
/
1
GbX5zRzYZHK
-
ZoFbbI2zQM2WOjafq2s
deployedBlock
=
17367500
isSyncLog
=
true
beforeEndReqUrl
=
https
://
meta
.
hapeprime
.
com
/
httpUrlRegex
= ^(
http
|
https
):\/\/[
a
-
zA
-
Z0
-
9
\-\.]+\.[
a
-
zA
-
Z
]{
2
,}(\/\
S
*)?$
goBackBlockNum
=
5
lotteryContract
=
0
x38BbA41d42D6ED244302a0D7561E98DA806a86DE
secret
=
0
x2Fc9Ba75f1c78ECc77D1a8fD3BDd6bA83eA68b7e
...
...
sync/Handler.go
View file @
751ac5c3
...
...
@@ -62,6 +62,10 @@ func LotteryContractHandler(vLog types.Log) error {
}
log
.
Info
(
"Insert data lottery:"
,
lottery
)
o
:=
orm
.
NewOrm
()
exist
:=
o
.
QueryTable
(
"lottery"
)
.
Filter
(
"hash"
,
lottery
.
Hash
)
.
Exist
()
if
exist
{
break
}
_
,
err
=
o
.
Insert
(
lottery
)
if
err
!=
nil
{
logs
.
Error
(
"Insert lottery error:"
,
err
.
Error
())
...
...
sync/sync.go
View file @
751ac5c3
...
...
@@ -74,6 +74,11 @@ func init() {
}
func
(
p
*
PullEvent
)
GetLogs
()
{
backBlock
,
err
:=
beego
.
AppConfig
.
Int64
(
"goBackBlockNum"
)
if
err
!=
nil
{
log
.
Error
(
"Get backBlock error:"
,
err
.
Error
())
return
}
query
:=
ethereum
.
FilterQuery
{}
query
.
FromBlock
=
p
.
lastBlock
query
.
ToBlock
=
new
(
big
.
Int
)
.
Add
(
p
.
lastBlock
,
big
.
NewInt
(
1
))
...
...
@@ -83,7 +88,7 @@ func (p *PullEvent) GetLogs() {
log
.
Info
(
"start fileter start at "
,
p
.
lastBlock
.
Text
(
10
))
height
,
err
:=
p
.
client
.
BlockNumber
(
p
.
ctx
)
log
.
Info
(
"current node height:"
,
height
)
if
height
<
=
p
.
lastBlock
.
Uint64
()
{
if
height
<
p
.
lastBlock
.
Uint64
()
{
time
.
Sleep
(
time
.
Second
)
continue
}
else
if
(
height
-
700
)
>=
p
.
lastBlock
.
Uint64
()
{
...
...
@@ -93,7 +98,8 @@ func (p *PullEvent) GetLogs() {
}
else
if
(
height
-
10
)
>=
p
.
lastBlock
.
Uint64
()
{
query
.
ToBlock
=
new
(
big
.
Int
)
.
Add
(
p
.
lastBlock
,
bigTen
)
}
else
{
query
.
ToBlock
=
new
(
big
.
Int
)
.
Add
(
p
.
lastBlock
,
bigOne
)
query
.
FromBlock
=
new
(
big
.
Int
)
.
Sub
(
p
.
lastBlock
,
big
.
NewInt
(
backBlock
))
query
.
ToBlock
=
p
.
lastBlock
}
allLogs
,
err
:=
p
.
client
.
FilterLogs
(
p
.
ctx
,
query
)
if
err
!=
nil
{
...
...
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