[#1902] engine, shard: Implement `TreeList` method

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
support/v0.34
Pavel Karpy 2022-10-18 15:49:40 +03:00 committed by Pavel Karpy
parent 2e199c7ab1
commit 24e9e3f3bf
3 changed files with 25 additions and 5 deletions

View File

@ -183,6 +183,24 @@ func (e *StorageEngine) TreeDrop(cid cidSDK.ID, treeID string) error {
// TreeList implements the pilorama.Forest interface.
func (e *StorageEngine) TreeList(cid cidSDK.ID) ([]string, error) {
//TODO implement me
panic("implement me")
var ids []string
var err error
for _, sh := range e.sortShardsByWeight(cid) {
ids, err = sh.TreeList(cid)
if err != nil {
if errors.Is(err, shard.ErrPiloramaDisabled) || errors.Is(err, shard.ErrReadOnlyMode) {
return nil, err
}
e.reportShardError(sh, "can't perform `TreeList`", err,
zap.Stringer("cid", cid))
continue
}
return ids, nil
}
return ids, err
}

View File

@ -193,7 +193,7 @@ func (f *memoryForest) TreeDrop(cid cidSDK.ID, treeID string) error {
return nil
}
// TreeGetTrees implements the pilorama.Forest interface.
// TreeList implements the pilorama.Forest interface.
func (f *memoryForest) TreeList(cid cidSDK.ID) ([]string, error) {
var res []string
cidStr := cid.EncodeToString()

View File

@ -87,6 +87,8 @@ func (s *Shard) TreeDrop(cid cidSDK.ID, treeID string) error {
// TreeList implements the pilorama.Forest interface.
func (s *Shard) TreeList(cid cidSDK.ID) ([]string, error) {
//TODO implement me
panic("implement me")
if s.pilorama == nil {
return nil, ErrPiloramaDisabled
}
return s.pilorama.TreeList(cid)
}