From ee72ced373855059d6d5c25b975a8e481a3ffbda Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Mon, 2 Oct 2023 13:08:36 +0200 Subject: [PATCH] Add locks --- suave/backends/local_store_backend.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/suave/backends/local_store_backend.go b/suave/backends/local_store_backend.go index cb9ff390ae..3e1727e9df 100644 --- a/suave/backends/local_store_backend.go +++ b/suave/backends/local_store_backend.go @@ -79,6 +79,9 @@ func (l *LocalConfidentialStore) Retrieve(bid suave.Bid, caller common.Address, } func (l *LocalConfidentialStore) FetchBidById(bidId suave.BidId) (suave.Bid, error) { + l.lock.Lock() + defer l.lock.Unlock() + bid, found := l.bids[bidId] if !found { return suave.Bid{}, errors.New("bid not found") @@ -88,6 +91,9 @@ func (l *LocalConfidentialStore) FetchBidById(bidId suave.BidId) (suave.Bid, err } func (l *LocalConfidentialStore) FetchBidsByProtocolAndBlock(blockNumber uint64, namespace string) []suave.Bid { + l.lock.Lock() + defer l.lock.Unlock() + indexKey := fmt.Sprintf("protocol-%s-bn-%d", namespace, blockNumber) bidIDs, ok := l.index[indexKey] if !ok {