Skip to content

Commit 3cead2a

Browse files
committed
Add PersistentSlabStorage.GetAllChildReferences()
This commit adds GetAllChildReferences() which essentially wraps an existing internal function.
1 parent 40aea0d commit 3cead2a

File tree

2 files changed

+1505
-0
lines changed

2 files changed

+1505
-0
lines changed

storage.go

+17
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,23 @@ func (s *PersistentSlabStorage) existIfLoaded(id StorageID) bool {
12361236
return false
12371237
}
12381238

1239+
// GetAllChildReferences returns child references of given slab (all levels),
1240+
// including nested container and theirs child references.
1241+
func (s *PersistentSlabStorage) GetAllChildReferences(id StorageID) (
1242+
references []StorageID,
1243+
brokenReferences []StorageID,
1244+
err error,
1245+
) {
1246+
slab, found, err := s.Retrieve(id)
1247+
if err != nil {
1248+
return nil, nil, err
1249+
}
1250+
if !found {
1251+
return nil, nil, NewSlabNotFoundErrorf(id, fmt.Sprintf("failed to get root slab by id %s", id))
1252+
}
1253+
return s.getAllChildReferences(slab)
1254+
}
1255+
12391256
// getAllChildReferences returns child references of given slab (all levels).
12401257
func (s *PersistentSlabStorage) getAllChildReferences(slab Slab) (
12411258
references []StorageID,

0 commit comments

Comments
 (0)