From 14d27455f3144625d4cc1441dcaaf18d8c9babd4 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 15 Feb 2022 12:53:35 +0300 Subject: [PATCH] [#1175] metabase: Add container bucket for LOCKs Create class of container buckets with `LOCKED` suffix. Put identifiers of the objects of type `LOCK` to these buckets during `DB.Put`. Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/metabase/lock.go | 13 +++++++++++++ pkg/local_object_storage/metabase/put.go | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 pkg/local_object_storage/metabase/lock.go diff --git a/pkg/local_object_storage/metabase/lock.go b/pkg/local_object_storage/metabase/lock.go new file mode 100644 index 000000000..5e5df53f4 --- /dev/null +++ b/pkg/local_object_storage/metabase/lock.go @@ -0,0 +1,13 @@ +package meta + +import ( + cid "github.com/nspcc-dev/neofs-sdk-go/container/id" +) + +// suffix for container buckets with locked objects. +const bucketNameSuffixLocked = invalidBase58String + "LOCKED" + +// returns name of the bucket with locked objects for specified container. +func bucketNameLocked(idCnr cid.ID) []byte { + return []byte(idCnr.String() + bucketNameSuffixLocked) +} diff --git a/pkg/local_object_storage/metabase/put.go b/pkg/local_object_storage/metabase/put.go index e12446d53..73360a8c5 100644 --- a/pkg/local_object_storage/metabase/put.go +++ b/pkg/local_object_storage/metabase/put.go @@ -198,6 +198,8 @@ func uniqueIndexes(obj *objectSDK.Object, si *objectSDK.SplitInfo, id *blobovnic bucketName = tombstoneBucketName(addr.ContainerID()) case objectSDK.TypeStorageGroup: bucketName = storageGroupBucketName(addr.ContainerID()) + case objectSDK.TypeLock: + bucketName = bucketNameLocked(*addr.ContainerID()) default: return nil, ErrUnknownObjectType }