Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
link33
plugin
Commits
c5af6db0
Commit
c5af6db0
authored
Dec 12, 2021
by
hezhengjun
Committed by
vipwzw
Dec 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make two client for ethereum relayer
parent
31886222
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
main.go
plugin/dapp/cross2eth/ebrelayer/main.go
+1
-0
ethereum.go
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
+11
-2
No files found.
plugin/dapp/cross2eth/ebrelayer/main.go
View file @
c5af6db0
...
...
@@ -91,6 +91,7 @@ func main() {
ethStartPara
:=
&
ethRelayer
.
EthereumStartPara
{
DbHandle
:
db
,
EthProvider
:
cfg
.
EthProvider
,
EthProviderHttp
:
cfg
.
EthProviderCli
,
BridgeRegistryAddr
:
cfg
.
BridgeRegistry
,
DeployInfo
:
cfg
.
Deploy
,
Degree
:
cfg
.
EthMaturityDegree
,
...
...
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
View file @
c5af6db0
...
...
@@ -42,6 +42,7 @@ import (
//Relayer4Ethereum ...
type
Relayer4Ethereum
struct
{
provider
string
providerHttp
string
clientChainID
*
big
.
Int
bridgeRegistryAddr
common
.
Address
db
dbm
.
DB
...
...
@@ -56,6 +57,7 @@ type Relayer4Ethereum struct {
fetchHeightPeriodMs
int32
eventLogIndex
ebTypes
.
EventLogIndex
clientSpec
ethinterface
.
EthClientSpec
clientWss
ethinterface
.
EthClientSpec
bridgeBankAddr
common
.
Address
bridgeBankSub
ethereum
.
Subscription
bridgeBankLog
chan
types
.
Log
...
...
@@ -86,6 +88,7 @@ const (
type
EthereumStartPara
struct
{
DbHandle
dbm
.
DB
EthProvider
string
EthProviderHttp
string
BridgeRegistryAddr
string
DeployInfo
*
ebTypes
.
Deploy
Degree
int32
...
...
@@ -101,6 +104,7 @@ func StartEthereumRelayer(startPara *EthereumStartPara) *Relayer4Ethereum {
}
ethRelayer
:=
&
Relayer4Ethereum
{
provider
:
startPara
.
EthProvider
,
providerHttp
:
startPara
.
EthProviderHttp
,
db
:
startPara
.
DbHandle
,
unlockchan
:
make
(
chan
int
,
2
),
bridgeRegistryAddr
:
common
.
HexToAddress
(
startPara
.
BridgeRegistryAddr
),
...
...
@@ -129,12 +133,17 @@ func StartEthereumRelayer(startPara *EthereumStartPara) *Relayer4Ethereum {
// Start clientSpec with infura ropsten provider
relayerLog
.
Info
(
"Relayer4Ethereum proc"
,
"Started Ethereum websocket with provider:"
,
ethRelayer
.
provider
)
client
,
err
:=
ethtxs
.
SetupWebsocketEthClient
(
ethRelayer
.
provider
)
client
,
err
:=
ethtxs
.
SetupWebsocketEthClient
(
ethRelayer
.
provider
Http
)
if
err
!=
nil
{
panic
(
err
)
}
ethRelayer
.
clientSpec
=
client
ethRelayer
.
clientWss
,
err
=
ethtxs
.
SetupWebsocketEthClient
(
ethRelayer
.
provider
)
if
err
!=
nil
{
panic
(
err
)
}
ctx
:=
context
.
Background
()
clientChainID
,
err
:=
client
.
NetworkID
(
ctx
)
if
err
!=
nil
{
...
...
@@ -809,7 +818,7 @@ func (ethRelayer *Relayer4Ethereum) subscribeEvent() {
// We will check logs for new events
logs
:=
make
(
chan
types
.
Log
,
10
)
// Filter by contract and event, write results to logs
sub
,
err
:=
ethRelayer
.
client
Spec
.
SubscribeFilterLogs
(
context
.
Background
(),
query
,
logs
)
sub
,
err
:=
ethRelayer
.
client
Wss
.
SubscribeFilterLogs
(
context
.
Background
(),
query
,
logs
)
if
err
!=
nil
{
errinfo
:=
fmt
.
Sprintf
(
"Failed to SubscribeFilterLogs due to:%s, bridgeBankAddr:%s"
,
err
.
Error
(),
ethRelayer
.
bridgeBankAddr
)
panic
(
errinfo
)
...
...
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