Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
token-bridge
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
movabridge
token-bridge
Commits
6e9e1227
Commit
6e9e1227
authored
Aug 20, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update sync block
parent
4c3ebd01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
16 deletions
+14
-16
Makefile
Makefile
+1
-1
sync.go
chain/sync.go
+11
-13
config.toml
config.toml
+2
-2
No files found.
Makefile
View file @
6e9e1227
...
@@ -13,6 +13,6 @@ dev:
...
@@ -13,6 +13,6 @@ dev:
go build
$(BUILD_FLAGS)
-v
-o
=
${
GOBIN
}
/
$@
-gcflags
"all=-N -l"
./cmd
go build
$(BUILD_FLAGS)
-v
-o
=
${
GOBIN
}
/
$@
-gcflags
"all=-N -l"
./cmd
docker
:
docker
:
docker build
-t
token-bridge:latest
-f
./Dockerfile .
docker build
-
-no-cache
-
t
token-bridge:latest
-f
./Dockerfile .
docker tag token-bridge:latest token-bridge:
$$
{
TAG:-latest
}
docker tag token-bridge:latest token-bridge:
$$
{
TAG:-latest
}
.PHONY
:
docker
.PHONY
:
docker
chain/sync.go
View file @
6e9e1227
...
@@ -48,25 +48,21 @@ func NewChainSync(_chain *config.ChainConfig, _d *dao.Dao) (sync *ChainSync) {
...
@@ -48,25 +48,21 @@ func NewChainSync(_chain *config.ChainConfig, _d *dao.Dao) (sync *ChainSync) {
func
(
s
*
ChainSync
)
loop
()
{
func
(
s
*
ChainSync
)
loop
()
{
defer
s
.
wg
.
Done
()
defer
s
.
wg
.
Done
()
last
Height
,
err
:=
s
.
d
.
GetStorageHeight
(
s
.
heightKey
)
finished
Height
,
err
:=
s
.
d
.
GetStorageHeight
(
s
.
heightKey
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
dao
.
ErrRecordNotFound
{
if
err
==
dao
.
ErrRecordNotFound
{
last
Height
=
s
.
chain
.
InitialHeight
finished
Height
=
s
.
chain
.
InitialHeight
}
else
{
}
else
{
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithField
(
"chain"
,
s
.
name
)
.
WithError
(
err
)
.
Error
(
"get last block height"
)
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithField
(
"chain"
,
s
.
name
)
.
WithError
(
err
)
.
Error
(
"get last block height"
)
return
return
}
}
}
}
if
lastHeight
!=
1
{
// 数据库里保存的是已完成的区块, 再次同步时+1
lastHeight
++
}
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithField
(
"height"
,
lastHeight
)
.
Info
(
"last validator block height"
)
var
latestHeight
int64
var
latestHeight
int64
var
beginHeight
=
lastHeight
var
beginHeight
=
finishedHeight
+
1
var
endHeight
=
beginHeight
+
int64
(
s
.
chain
.
BatchBlock
)
var
endHeight
=
beginHeight
+
int64
(
s
.
chain
.
BatchBlock
)
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithField
(
"begin height"
,
beginHeight
)
.
Info
(
"last validator block height"
)
tm
:=
time
.
NewTicker
(
time
.
Second
)
tm
:=
time
.
NewTicker
(
time
.
Second
)
defer
tm
.
Stop
()
defer
tm
.
Stop
()
...
@@ -79,19 +75,21 @@ func (s *ChainSync) loop() {
...
@@ -79,19 +75,21 @@ func (s *ChainSync) loop() {
latestHeight
,
err
=
s
.
d
.
GetBlockHeight
(
s
.
chain
,
s
.
chain
.
BehindBlock
)
latestHeight
,
err
=
s
.
d
.
GetBlockHeight
(
s
.
chain
,
s
.
chain
.
BehindBlock
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithError
(
err
)
.
Error
(
"get latest block height"
)
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithError
(
err
)
.
Error
(
"get latest block height"
)
time
.
Sleep
(
time
.
Second
)
continue
continue
}
}
if
(
latestHeight
-
int64
(
s
.
chain
.
BatchBlock
)
-
1
)
-
beginHeight
<
int64
(
s
.
chain
.
BatchBlock
)
{
if
latestHeight
<=
beginHeight
{
time
.
Sleep
(
2
*
time
.
Second
)
continue
continue
}
}
if
latestHeight
<
endHeight
{
endHeight
=
latestHeight
}
if
err
:=
s
.
SyncLogs
(
beginHeight
,
endHeight
);
err
!=
nil
{
if
err
:=
s
.
SyncLogs
(
beginHeight
,
endHeight
);
err
!=
nil
{
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithFields
(
log
.
Fields
{
log
.
WithField
(
"chain"
,
s
.
name
)
.
WithFields
(
log
.
Fields
{
"begin height"
:
beginHeight
,
"begin height"
:
beginHeight
,
"end height"
:
endHeight
,
"end height"
:
endHeight
,
})
.
WithError
(
err
)
.
Error
(
"sync logs failed"
)
})
.
WithError
(
err
)
.
Error
(
"sync logs failed"
)
time
.
Sleep
(
time
.
Second
)
continue
continue
}
}
...
...
config.toml
View file @
6e9e1227
...
@@ -4,7 +4,7 @@ debug = true
...
@@ -4,7 +4,7 @@ debug = true
name
=
"hpb"
name
=
"hpb"
rpc
=
"https://hpbnode.com"
rpc
=
"https://hpbnode.com"
initial_height
=
23240125
initial_height
=
23240125
batch_block
=
2
batch_block
=
100
confirm_block_count
=
2
confirm_block_count
=
2
bridge_contract
=
"0x9a06d0CfAFc19a4bfe0ecd5f8bC20A26a88fA227"
bridge_contract
=
"0x9a06d0CfAFc19a4bfe0ecd5f8bC20A26a88fA227"
validator_private_key
=
"fc35cdedfab10b7218ae68b45146736bc66513452000f1fa411ff7a9c1f33439"
validator_private_key
=
"fc35cdedfab10b7218ae68b45146736bc66513452000f1fa411ff7a9c1f33439"
...
@@ -13,7 +13,7 @@ validator_private_key = "fc35cdedfab10b7218ae68b45146736bc66513452000f1fa411ff7a
...
@@ -13,7 +13,7 @@ validator_private_key = "fc35cdedfab10b7218ae68b45146736bc66513452000f1fa411ff7a
name
=
"bit"
name
=
"bit"
rpc
=
"https://rpc.mova.bitheart.org"
rpc
=
"https://rpc.mova.bitheart.org"
initial_height
=
1123988
initial_height
=
1123988
batch_block
=
2
batch_block
=
100
confirm_block_count
=
2
confirm_block_count
=
2
bridge_contract
=
"0x9a06d0CfAFc19a4bfe0ecd5f8bC20A26a88fA227"
bridge_contract
=
"0x9a06d0CfAFc19a4bfe0ecd5f8bC20A26a88fA227"
validator_private_key
=
"fc35cdedfab10b7218ae68b45146736bc66513452000f1fa411ff7a9c1f33439"
validator_private_key
=
"fc35cdedfab10b7218ae68b45146736bc66513452000f1fa411ff7a9c1f33439"
...
...
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