Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bridge-backend
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
bridge-backend
Commits
9b7cd81c
Commit
9b7cd81c
authored
Sep 18, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update get block time
parent
c5037ac1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
eth.go
dao/eth.go
+4
-2
eth_test.go
dao/eth_test.go
+10
-0
No files found.
dao/eth.go
View file @
9b7cd81c
...
@@ -56,9 +56,11 @@ func (d *Dao) GetBlockTime(chain *config.ChainConfig, height int64) (timestamp i
...
@@ -56,9 +56,11 @@ func (d *Dao) GetBlockTime(chain *config.ChainConfig, height int64) (timestamp i
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
block
,
err
:=
chainInfo
.
cli
.
Block
ByNumber
(
ctx
,
big
.
NewInt
(
int64
(
height
)))
header
,
err
:=
chainInfo
.
cli
.
Header
ByNumber
(
ctx
,
big
.
NewInt
(
int64
(
height
)))
if
err
==
nil
{
if
err
==
nil
{
return
int64
(
block
.
Time
()),
nil
return
int64
(
header
.
Time
),
nil
}
else
{
time
.
Sleep
(
500
*
time
.
Millisecond
)
}
}
}
}
return
return
...
...
dao/eth_test.go
View file @
9b7cd81c
...
@@ -11,6 +11,16 @@ import (
...
@@ -11,6 +11,16 @@ import (
"testing"
"testing"
)
)
func
TestGetBlockTime
(
t
*
testing
.
T
)
{
client
,
_
:=
ethclient
.
Dial
(
"https://bsctest.bitheart.org"
)
height
:=
big
.
NewInt
(
65784850
)
block
,
err
:=
client
.
HeaderByNumber
(
context
.
Background
(),
height
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Println
(
block
.
Time
())
}
func
TestGetReceiveToken
(
t
*
testing
.
T
)
{
func
TestGetReceiveToken
(
t
*
testing
.
T
)
{
client
,
_
:=
ethclient
.
Dial
(
"http://rpc.hole.bitheart.org"
)
client
,
_
:=
ethclient
.
Dial
(
"http://rpc.hole.bitheart.org"
)
ct
,
_
:=
bridge
.
NewBridgeContract
(
common
.
HexToAddress
(
"0xceEC8799139C698De532e363DA7395E25F409775"
),
client
)
ct
,
_
:=
bridge
.
NewBridgeContract
(
common
.
HexToAddress
(
"0xceEC8799139C698De532e363DA7395E25F409775"
),
client
)
...
...
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