From c73dec31f22ef056a5afcef87296c753e58c84d0 Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Mon, 18 Mar 2024 14:19:55 +0400 Subject: [PATCH] Fix data race b/c of lacking lock protection for "data" slice Signed-off-by: Anton Litvinov --- session/pingpong/consumer_totals_storage.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/session/pingpong/consumer_totals_storage.go b/session/pingpong/consumer_totals_storage.go index b890e930c3..dd035af7b9 100644 --- a/session/pingpong/consumer_totals_storage.go +++ b/session/pingpong/consumer_totals_storage.go @@ -94,6 +94,9 @@ func (cts *ConsumerTotalsStorage) Store(chainID int64, id identity.Identity, her // Get fetches the amount as promised for the given channel. func (cts *ConsumerTotalsStorage) Get(chainID int64, id identity.Identity, hermesID common.Address) (*big.Int, error) { key := cts.makeKey(chainID, id, hermesID) + cts.createLock.Lock() + defer cts.createLock.Unlock() + element, ok := cts.data[key] if !ok { return nil, ErrNotFound