2020-07-10 14:17:51 +00:00
|
|
|
package localstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/refs"
|
2020-07-24 13:54:03 +00:00
|
|
|
metrics2 "github.com/nspcc-dev/neofs-node/pkg/services/metrics"
|
2020-07-10 14:17:51 +00:00
|
|
|
"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,
|
2020-07-24 13:54:03 +00:00
|
|
|
metrics2.AddSpace)
|
2020-07-10 14:17:51 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|