Fixed concurrent write to blockchain status map

This commit is contained in:
Ivan Belyakov 2023-06-28 15:39:13 +02:00 committed by IvanBelyakoff
parent b058ab41da
commit 1efecbf73b
1 changed files with 5 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package wallet
import (
"database/sql"
"encoding/json"
"sync"
"time"
"github.com/ethereum/go-ethereum/common"
@ -59,7 +60,11 @@ func NewService(
Publisher: walletFeed,
}
blockchainStatus := make(map[uint64]string)
mutex := sync.Mutex{}
rpcClient.SetWalletNotifier(func(chainID uint64, message string) {
mutex.Lock()
defer mutex.Unlock()
if len(blockchainStatus) == 0 {
networks, err := rpcClient.NetworkManager.Get(false)
if err != nil {