Skip to content

Commit

Permalink
Merge pull request #391 from onflow/fxamacker/export-getAllChildRefer…
Browse files Browse the repository at this point in the history
…ences

Add PersistentSlabStorage.GetAllChildReferences()
  • Loading branch information
fxamacker authored Apr 16, 2024
2 parents 40aea0d + 3cead2a commit 4b0f707
Show file tree
Hide file tree
Showing 2 changed files with 1,505 additions and 0 deletions.
17 changes: 17 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,23 @@ func (s *PersistentSlabStorage) existIfLoaded(id StorageID) bool {
return false
}

// GetAllChildReferences returns child references of given slab (all levels),
// including nested container and theirs child references.
func (s *PersistentSlabStorage) GetAllChildReferences(id StorageID) (
references []StorageID,
brokenReferences []StorageID,
err error,
) {
slab, found, err := s.Retrieve(id)
if err != nil {
return nil, nil, err
}
if !found {
return nil, nil, NewSlabNotFoundErrorf(id, fmt.Sprintf("failed to get root slab by id %s", id))
}
return s.getAllChildReferences(slab)
}

// getAllChildReferences returns child references of given slab (all levels).
func (s *PersistentSlabStorage) getAllChildReferences(slab Slab) (
references []StorageID,
Expand Down
Loading

0 comments on commit 4b0f707

Please sign in to comment.