Skip to content

Commit

Permalink
Add locks
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt committed Oct 2, 2023
1 parent f74e792 commit ee72ced
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions suave/backends/local_store_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand Down

0 comments on commit ee72ced

Please sign in to comment.