Skip to content

Commit

Permalink
Fix data race b/c of lacking lock protection for "data" slice
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Litvinov <[email protected]>
  • Loading branch information
Zensey committed Mar 26, 2024
1 parent 453bb8b commit c73dec3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions session/pingpong/consumer_totals_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c73dec3

Please sign in to comment.