Skip to content

Commit

Permalink
container/delete: delete meta info from storage when container is del…
Browse files Browse the repository at this point in the history
…eted

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Dec 20, 2024
1 parent 8f96b35 commit 05d6451
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions contracts/container/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,10 @@ func removeContainer(ctx storage.Context, id []byte, owner []byte) {
containerListKey = append(containerListKey, id...)
storage.Delete(ctx, containerListKey)

deleteByPrefix(ctx, append([]byte{nodesPrefix}, id...))
deleteByPrefix(ctx, append([]byte{nextEpochNodesPrefix}, id...))
deleteByPrefix(ctx, append([]byte{replicasNumberPrefix}, id...))

storage.Delete(ctx, append([]byte{containerKeyPrefix}, id...))
storage.Delete(ctx, append([]byte{containersWithMetaPrefix}, id...))
storage.Delete(ctx, append(eACLPrefix, id...))
Expand Down Expand Up @@ -1168,3 +1172,10 @@ func cleanupContainers(ctx storage.Context, epoch int) {
}
}
}

func deleteByPrefix(ctx storage.Context, prefix []byte) {
it := storage.Find(ctx, prefix, storage.KeysOnly)
for iterator.Next(it) {
storage.Delete(ctx, iterator.Value(it).([]byte))
}
}
Binary file modified contracts/container/contract.nef
Binary file not shown.

0 comments on commit 05d6451

Please sign in to comment.