Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ func (cs *CachedStorage) RetrieveBlock(seq uint64, digest common.Digest) (metada
func (cs *CachedStorage) Retrieve(seq uint64, digest common.Digest) (common.VerifiedBlock, *common.Finalization, error) {
cs.lock.RLock()
item, exists := cs.cache[digest]
if !exists && digest == (common.Digest{}) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test that tests the added lines.

// Seq-only lookups pass a zero digest, so scan the cache by seq.
// Otherwise a verified but not yet finalized block is invisible to them.
for _, cb := range cs.cache {
Comment thread
samliok marked this conversation as resolved.
Outdated
if cb.Metadata.SimplexProtocolMetadata.Seq == seq {
item, exists = cb, true
break
}
}
}
if exists {
cs.lock.RUnlock()
// If the block is cached, it means it's not finalized yet, because upon finalizing the block (indexing)
Expand Down
Loading