forked from TrueCloudLab/frostfs-node
Initial commit
Initial public review release v0.10.0
This commit is contained in:
commit
dadfd90dcd
276 changed files with 46331 additions and 0 deletions
47
lib/localstore/put.go
Normal file
47
lib/localstore/put.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
package localstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/refs"
|
||||
"github.com/nspcc-dev/neofs-node/lib/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,
|
||||
metrics.AddSpace)
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue