47 lines
1 KiB
Go
47 lines
1 KiB
Go
package localstore
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/refs"
|
|
metrics2 "github.com/nspcc-dev/neofs-node/pkg/services/metrics"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (l *localstore) Put(ctx context.Context, obj *Object) error {
|
|
var (
|
|
oa refs.Address
|
|
k, v []byte
|
|
err error
|
|
)
|
|
|
|
oa = *obj.Address()
|
|
k, err = oa.Hash()
|
|
|
|
if err != nil {
|
|
return errors.Wrap(err, "Localstore Put failed on StorageKey.marshal")
|
|
}
|
|
|
|
if v, err = obj.Marshal(); err != nil {
|
|
return errors.Wrap(err, "Localstore Put failed on blobValue")
|
|
}
|
|
|
|
if err = l.blobBucket.Set(k, v); err != nil {
|
|
return errors.Wrap(err, "Localstore Put failed on BlobBucket.Set")
|
|
}
|
|
|
|
if v, err = metaFromObject(ctx, obj).Marshal(); err != nil {
|
|
return errors.Wrap(err, "Localstore Put failed on metaValue")
|
|
}
|
|
|
|
if err = l.metaBucket.Set(k, v); err != nil {
|
|
return errors.Wrap(err, "Localstore Put failed on MetaBucket.Set")
|
|
}
|
|
|
|
l.col.UpdateContainer(
|
|
obj.SystemHeader.CID,
|
|
obj.SystemHeader.PayloadLength,
|
|
metrics2.AddSpace)
|
|
|
|
return nil
|
|
}
|