Skip to content

Commit

Permalink
fix: Iterate pendingWrites backward to get the last updated value (#285)
Browse files Browse the repository at this point in the history
fix: Iterate pendingWrites backward to get the latest update
  • Loading branch information
pistomat authored Nov 14, 2024
1 parent 92588d8 commit e96d433
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion suave/cstore/transactional_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func (s *TransactionalStore) Retrieve(dataId suave.DataId, caller common.Address

s.pendingLock.Lock()

for _, sw := range s.pendingWrites {
for i := len(s.pendingWrites) - 1; i >= 0; i-- {
sw := s.pendingWrites[i]
if sw.DataRecord.Id == record.Id && sw.Key == key {
s.pendingLock.Unlock()
return common.CopyBytes(sw.Value), nil
Expand Down

0 comments on commit e96d433

Please sign in to comment.