forked from TrueCloudLab/frostfs-node
[#30] Update to latest neofs-api-go and fix conflicts
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
84b4ff0755
commit
9c1c023f05
6 changed files with 25 additions and 33 deletions
2
go.mod
2
go.mod
|
@ -13,7 +13,7 @@ require (
|
|||
github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2
|
||||
github.com/multiformats/go-multihash v0.0.13 // indirect
|
||||
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200911095622-47fd771ee4c5
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200916115135-ff325b877023
|
||||
github.com/nspcc-dev/neofs-crypto v0.3.0
|
||||
github.com/panjf2000/ants/v2 v2.3.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -19,17 +19,12 @@ func (a *Address) MarshalStableV2() ([]byte, error) {
|
|||
}
|
||||
|
||||
// AddressFromV2 converts v2 Address message to Address.
|
||||
func AddressFromV2(aV2 *refs.Address) (*Address, error) {
|
||||
func AddressFromV2(aV2 *refs.Address) *Address {
|
||||
if aV2 == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
a, err := object.AddressFromV2(aV2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil
|
||||
}
|
||||
|
||||
return &Address{
|
||||
Address: a,
|
||||
}, nil
|
||||
Address: object.NewAddressFromV2(aV2),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package object
|
|||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
)
|
||||
|
||||
// Object represents the NeoFS object.
|
||||
|
@ -17,12 +18,7 @@ type Object struct {
|
|||
// MarshalStableV2 marshals Object to v2 binary format.
|
||||
func (o *Object) MarshalStableV2() ([]byte, error) {
|
||||
if o != nil {
|
||||
v2, err := o.ToV2(nil) // fixme: remove
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return v2.StableMarshal(nil)
|
||||
return o.ToV2().StableMarshal(nil)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
|
@ -31,8 +27,12 @@ func (o *Object) MarshalStableV2() ([]byte, error) {
|
|||
// Address returns address of the object.
|
||||
func (o *Object) Address() *Address {
|
||||
if o != nil {
|
||||
aV2 := new(refs.Address)
|
||||
aV2.SetObjectID(o.GetID().ToV2())
|
||||
aV2.SetContainerID(o.GetContainerID().ToV2())
|
||||
|
||||
return &Address{
|
||||
Address: o.Object.Address(),
|
||||
Address: object.NewAddressFromV2(aV2),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,19 +40,14 @@ func (o *Object) Address() *Address {
|
|||
}
|
||||
|
||||
// FromV2 converts v2 Object message to Object.
|
||||
func FromV2(oV2 *objectV2.Object) (*Object, error) {
|
||||
func FromV2(oV2 *objectV2.Object) *Object {
|
||||
if oV2 == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
o, err := object.FromV2(oV2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil
|
||||
}
|
||||
|
||||
return &Object{
|
||||
Object: o,
|
||||
}, nil
|
||||
Object: object.NewFromV2(oV2),
|
||||
}
|
||||
}
|
||||
|
||||
// FromBytes restores Object from binary format.
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/binary"
|
||||
"io"
|
||||
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -44,8 +45,14 @@ func metaFromObject(o *object.Object) *ObjectMeta {
|
|||
// FIXME: remove hard-code
|
||||
meta := new(ObjectMeta)
|
||||
meta.savedAtEpoch = 10
|
||||
|
||||
raw := objectSDK.NewRaw()
|
||||
raw.SetContainerID(o.GetContainerID())
|
||||
raw.SetOwnerID(o.GetOwnerID())
|
||||
// TODO: set other meta fields
|
||||
|
||||
meta.head = &object.Object{
|
||||
Object: o.CutPayload(),
|
||||
Object: raw.Object(),
|
||||
}
|
||||
|
||||
return meta
|
||||
|
|
|
@ -20,12 +20,7 @@ func NewExecutor(client *wrapper.Wrapper) accountingSvc.ServiceExecutor {
|
|||
}
|
||||
|
||||
func (s *morphExecutor) Balance(ctx context.Context, body *accounting.BalanceRequestBody) (*accounting.BalanceResponseBody, error) {
|
||||
id, err := owner.IDFromV2(body.GetOwnerID())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
amount, err := s.client.BalanceOf(id)
|
||||
amount, err := s.client.BalanceOf(owner.NewIDFromV2(body.GetOwnerID()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue