Skip to content

Commit

Permalink
update Sponsor
Browse files Browse the repository at this point in the history
  • Loading branch information
cherry-yl-sh committed May 28, 2024
1 parent 2ab2e64 commit 7c79240
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions common/network/ethereum_adaptable_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/xerrors"
"math/big"
"strings"
"sync"
)

Expand Down Expand Up @@ -60,11 +61,12 @@ func init() {

type EthereumExecutor struct {
BaseExecutor
Client *ethclient.Client
GethClient *gethclient.Client
network global_const.Network
ChainId *big.Int
eventListener schedulor.EventListener
Client *ethclient.Client
GethClient *gethclient.Client
network global_const.Network
ChainId *big.Int
eventListener schedulor.EventListener
webSocketClient *ethclient.Client
}

var mu sync.Mutex
Expand Down Expand Up @@ -94,19 +96,27 @@ func GetEthereumExecutor(network global_const.Network) *EthereumExecutor {
if !success {
panic(xerrors.Errorf("chainId %s is invalid", config.GetChainId(network)))
}
eventListener, err := schedulor.NewEventListener(client, network)
wsUrl := config.GetNewWorkClientURl(network)
wsUrl = strings.Replace(wsUrl, "https", "wss", 1)
webSocketClient, err := ethclient.Dial(wsUrl)
if err != nil {
panic(err)
}

eventListener, err := schedulor.NewEventListener(webSocketClient, network)
if err != nil {
panic(err)
}
go eventListener.Listen()
logrus.Debugf("after Lesten network :[%s]", network)
geth := gethclient.New(client.Client())
executorMap[network] = &EthereumExecutor{
network: network,
Client: client,
ChainId: chainId,
GethClient: geth,
eventListener: eventListener,
network: network,
Client: client,
ChainId: chainId,
GethClient: geth,
eventListener: eventListener,
webSocketClient: webSocketClient,
}

return executorMap[network]
Expand Down

0 comments on commit 7c79240

Please sign in to comment.