Fixed concurrent write to blockchain status map
This commit is contained in:
parent
b058ab41da
commit
1efecbf73b
|
@ -3,6 +3,7 @@ package wallet
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
@ -59,7 +60,11 @@ func NewService(
|
||||||
Publisher: walletFeed,
|
Publisher: walletFeed,
|
||||||
}
|
}
|
||||||
blockchainStatus := make(map[uint64]string)
|
blockchainStatus := make(map[uint64]string)
|
||||||
|
mutex := sync.Mutex{}
|
||||||
rpcClient.SetWalletNotifier(func(chainID uint64, message string) {
|
rpcClient.SetWalletNotifier(func(chainID uint64, message string) {
|
||||||
|
mutex.Lock()
|
||||||
|
defer mutex.Unlock()
|
||||||
|
|
||||||
if len(blockchainStatus) == 0 {
|
if len(blockchainStatus) == 0 {
|
||||||
networks, err := rpcClient.NetworkManager.Get(false)
|
networks, err := rpcClient.NetworkManager.Get(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue