[#174] subnet: Clear all storage keys in Delete
method
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
e9d5e57caf
commit
0e84900187
1 changed files with 20 additions and 0 deletions
|
@ -174,6 +174,18 @@ func Delete(id []byte) {
|
|||
key[0] = infoPrefix
|
||||
storage.Delete(ctx, key)
|
||||
|
||||
key[0] = nodeAdminPrefix
|
||||
deleteByPrefix(ctx, key)
|
||||
|
||||
key[0] = nodePrefix
|
||||
deleteByPrefix(ctx, key)
|
||||
|
||||
key[0] = clientAdminPrefix
|
||||
deleteByPrefix(ctx, key)
|
||||
|
||||
key[0] = userPrefix
|
||||
deleteByPrefix(ctx, key)
|
||||
|
||||
runtime.Notify("Delete", id)
|
||||
}
|
||||
|
||||
|
@ -571,6 +583,14 @@ func deleteKeyFromList(ctx storage.Context, keyToDelete interop.PublicKey, prefi
|
|||
storage.Delete(ctx, append(prefix, keyToDelete...))
|
||||
}
|
||||
|
||||
func deleteByPrefix(ctx storage.Context, prefix []byte) {
|
||||
iter := storage.Find(ctx, prefix, storage.KeysOnly)
|
||||
for iterator.Next(iter) {
|
||||
k := iterator.Value(iter).([]byte)
|
||||
storage.Delete(ctx, k)
|
||||
}
|
||||
}
|
||||
|
||||
func calledByOwnerOrAdmin(ctx storage.Context, owner []byte, adminPrefix []byte) bool {
|
||||
if runtime.CheckWitness(owner) {
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue