From fc43794c7ebf1d4f8829df6d9397536471c47418 Mon Sep 17 00:00:00 2001 From: pistomat Date: Tue, 12 Nov 2024 13:20:01 +0100 Subject: [PATCH] fix: Iterate pendingWrites backward to get the latest update --- suave/cstore/transactional_store.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/suave/cstore/transactional_store.go b/suave/cstore/transactional_store.go index 4e0bfc088..2cc7558b9 100644 --- a/suave/cstore/transactional_store.go +++ b/suave/cstore/transactional_store.go @@ -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