forked from TrueCloudLab/frostfs-node
[#521] *: use stdlib errors
package
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
43e575cec2
commit
71b87155ef
171 changed files with 825 additions and 674 deletions
|
@ -1,11 +1,12 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Lock structure of balance.Lock notification from morph chain.
|
||||
|
@ -49,41 +50,41 @@ func ParseLock(params []stackitem.Item) (event.Event, error) {
|
|||
// parse id
|
||||
ev.id, err = client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get lock id")
|
||||
return nil, fmt.Errorf("could not get lock id: %w", err)
|
||||
}
|
||||
|
||||
// parse user
|
||||
user, err := client.BytesFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get lock user value")
|
||||
return nil, fmt.Errorf("could not get lock user value: %w", err)
|
||||
}
|
||||
|
||||
ev.user, err = util.Uint160DecodeBytesBE(user)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert lock user value to uint160")
|
||||
return nil, fmt.Errorf("could not convert lock user value to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse lock account
|
||||
lock, err := client.BytesFromStackItem(params[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get lock account value")
|
||||
return nil, fmt.Errorf("could not get lock account value: %w", err)
|
||||
}
|
||||
|
||||
ev.lock, err = util.Uint160DecodeBytesBE(lock)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert lock account value to uint160")
|
||||
return nil, fmt.Errorf("could not convert lock account value to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse amount
|
||||
ev.amount, err = client.IntFromStackItem(params[3])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get lock amount")
|
||||
return nil, fmt.Errorf("could not get lock amount: %w", err)
|
||||
}
|
||||
|
||||
// parse until deadline
|
||||
ev.until, err = client.IntFromStackItem(params[4])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get lock deadline")
|
||||
return nil, fmt.Errorf("could not get lock deadline: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Delete structure of container.Delete notification from morph chain.
|
||||
|
@ -36,13 +37,13 @@ func ParseDelete(params []stackitem.Item) (event.Event, error) {
|
|||
// parse container
|
||||
ev.containerID, err = client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get container")
|
||||
return nil, fmt.Errorf("could not get container: %w", err)
|
||||
}
|
||||
|
||||
// parse signature
|
||||
ev.signature, err = client.BytesFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get signature")
|
||||
return nil, fmt.Errorf("could not get signature: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// StartEstimation structure of container.StartEstimation notification from
|
||||
|
@ -59,7 +60,7 @@ func parseEstimation(params []stackitem.Item) (uint64, error) {
|
|||
// parse container
|
||||
epoch, err := client.IntFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "could not get estimation epoch")
|
||||
return 0, fmt.Errorf("could not get estimation epoch: %w", err)
|
||||
}
|
||||
|
||||
return uint64(epoch), nil
|
||||
|
|
|
@ -2,12 +2,12 @@ package container
|
|||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Put structure of container.Put notification from morph chain.
|
||||
|
@ -43,24 +43,24 @@ func ParsePut(params []stackitem.Item) (event.Event, error) {
|
|||
// parse container
|
||||
ev.rawContainer, err = client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get container")
|
||||
return nil, fmt.Errorf("could not get container: %w", err)
|
||||
}
|
||||
|
||||
// parse signature
|
||||
ev.signature, err = client.BytesFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get signature")
|
||||
return nil, fmt.Errorf("could not get signature: %w", err)
|
||||
}
|
||||
|
||||
// parse public key
|
||||
key, err := client.BytesFromStackItem(params[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get public key")
|
||||
return nil, fmt.Errorf("could not get public key: %w", err)
|
||||
}
|
||||
|
||||
ev.publicKey, err = keys.NewPublicKeyFromBytes(key, elliptic.P256())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse public key")
|
||||
return nil, fmt.Errorf("could not parse public key: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -2,6 +2,8 @@ package event
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
|
@ -9,7 +11,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/subscriber"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -160,7 +161,7 @@ func (s listener) listenLoop(ctx context.Context, chEvent <-chan *state.Notifica
|
|||
var err error
|
||||
if blockChan, err = s.subscriber.BlockNotifications(); err != nil {
|
||||
if intErr != nil {
|
||||
intErr <- errors.Wrap(err, "could not open block notifications channel")
|
||||
intErr <- fmt.Errorf("could not open block notifications channel: %w", err)
|
||||
} else {
|
||||
s.log.Debug("could not open block notifications channel",
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -372,9 +373,9 @@ func (s *listener) RegisterBlockHandler(handler BlockHandler) {
|
|||
func NewListener(p ListenerParams) (Listener, error) {
|
||||
switch {
|
||||
case p.Logger == nil:
|
||||
return nil, errors.Wrap(errNilLogger, newListenerFailMsg)
|
||||
return nil, fmt.Errorf("%s: %w", newListenerFailMsg, errNilLogger)
|
||||
case p.Subscriber == nil:
|
||||
return nil, errors.Wrap(errNilSubscriber, newListenerFailMsg)
|
||||
return nil, fmt.Errorf("%s: %w", newListenerFailMsg, errNilSubscriber)
|
||||
}
|
||||
|
||||
return &listener{
|
||||
|
|
|
@ -2,13 +2,13 @@ package neofs
|
|||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Bind struct {
|
||||
|
@ -36,30 +36,30 @@ func ParseBind(params []stackitem.Item) (event.Event, error) {
|
|||
// parse user
|
||||
user, err := client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get bind user")
|
||||
return nil, fmt.Errorf("could not get bind user: %w", err)
|
||||
}
|
||||
|
||||
ev.user, err = util.Uint160DecodeBytesBE(user)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert bind user to uint160")
|
||||
return nil, fmt.Errorf("could not convert bind user to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse keys
|
||||
bindKeys, err := client.ArrayFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get bind keys")
|
||||
return nil, fmt.Errorf("could not get bind keys: %w", err)
|
||||
}
|
||||
|
||||
ev.keys = make([]*keys.PublicKey, 0, len(bindKeys))
|
||||
for i := range bindKeys {
|
||||
rawKey, err := client.BytesFromStackItem(bindKeys[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get bind public key")
|
||||
return nil, fmt.Errorf("could not get bind public key: %w", err)
|
||||
}
|
||||
|
||||
key, err := keys.NewPublicKeyFromBytes(rawKey, elliptic.P256())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse bind public key")
|
||||
return nil, fmt.Errorf("could not parse bind public key: %w", err)
|
||||
}
|
||||
|
||||
ev.keys = append(ev.keys, key)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package neofs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Cheque structure of neofs.Cheque notification from mainnet chain.
|
||||
|
@ -45,35 +46,35 @@ func ParseCheque(params []stackitem.Item) (event.Event, error) {
|
|||
// parse id
|
||||
ev.id, err = client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get cheque id")
|
||||
return nil, fmt.Errorf("could not get cheque id: %w", err)
|
||||
}
|
||||
|
||||
// parse user
|
||||
user, err := client.BytesFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get cheque user")
|
||||
return nil, fmt.Errorf("could not get cheque user: %w", err)
|
||||
}
|
||||
|
||||
ev.user, err = util.Uint160DecodeBytesBE(user)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert cheque user to uint160")
|
||||
return nil, fmt.Errorf("could not convert cheque user to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse amount
|
||||
ev.amount, err = client.IntFromStackItem(params[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get cheque amount")
|
||||
return nil, fmt.Errorf("could not get cheque amount: %w", err)
|
||||
}
|
||||
|
||||
// parse lock account
|
||||
lock, err := client.BytesFromStackItem(params[3])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get cheque lock account")
|
||||
return nil, fmt.Errorf("could not get cheque lock account: %w", err)
|
||||
}
|
||||
|
||||
ev.lock, err = util.Uint160DecodeBytesBE(lock)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert cheque lock account to uint160")
|
||||
return nil, fmt.Errorf("could not convert cheque lock account to uint160: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package neofs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
@ -35,19 +36,19 @@ func ParseConfig(params []stackitem.Item) (event.Event, error) {
|
|||
// parse id
|
||||
ev.id, err = client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get config update id")
|
||||
return nil, fmt.Errorf("could not get config update id: %w", err)
|
||||
}
|
||||
|
||||
// parse key
|
||||
ev.key, err = client.BytesFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get config key")
|
||||
return nil, fmt.Errorf("could not get config key: %w", err)
|
||||
}
|
||||
|
||||
// parse value
|
||||
ev.value, err = client.BytesFromStackItem(params[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get config value")
|
||||
return nil, fmt.Errorf("could not get config value: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package neofs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Deposit structure of neofs.Deposit notification from mainnet chain.
|
||||
|
@ -42,35 +43,35 @@ func ParseDeposit(params []stackitem.Item) (event.Event, error) {
|
|||
// parse from
|
||||
from, err := client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get deposit sender")
|
||||
return nil, fmt.Errorf("could not get deposit sender: %w", err)
|
||||
}
|
||||
|
||||
ev.from, err = util.Uint160DecodeBytesBE(from)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert deposit sender to uint160")
|
||||
return nil, fmt.Errorf("could not convert deposit sender to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse amount
|
||||
ev.amount, err = client.IntFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get deposit amount")
|
||||
return nil, fmt.Errorf("could not get deposit amount: %w", err)
|
||||
}
|
||||
|
||||
// parse to
|
||||
to, err := client.BytesFromStackItem(params[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get deposit receiver")
|
||||
return nil, fmt.Errorf("could not get deposit receiver: %w", err)
|
||||
}
|
||||
|
||||
ev.to, err = util.Uint160DecodeBytesBE(to)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert deposit receiver to uint160")
|
||||
return nil, fmt.Errorf("could not convert deposit receiver to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse id
|
||||
ev.id, err = client.BytesFromStackItem(params[3])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get deposit id")
|
||||
return nil, fmt.Errorf("could not get deposit id: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -2,12 +2,12 @@ package neofs
|
|||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type UpdateInnerRing struct {
|
||||
|
@ -32,19 +32,19 @@ func ParseUpdateInnerRing(params []stackitem.Item) (event.Event, error) {
|
|||
// parse keys
|
||||
irKeys, err := client.ArrayFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get updated inner ring keys")
|
||||
return nil, fmt.Errorf("could not get updated inner ring keys: %w", err)
|
||||
}
|
||||
|
||||
ev.keys = make([]*keys.PublicKey, 0, len(irKeys))
|
||||
for i := range irKeys {
|
||||
rawKey, err := client.BytesFromStackItem(irKeys[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get updated inner ring public key")
|
||||
return nil, fmt.Errorf("could not get updated inner ring public key: %w", err)
|
||||
}
|
||||
|
||||
key, err := keys.NewPublicKeyFromBytes(rawKey, elliptic.P256())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse updated inner ring public key")
|
||||
return nil, fmt.Errorf("could not parse updated inner ring public key: %w", err)
|
||||
}
|
||||
|
||||
ev.keys = append(ev.keys, key)
|
||||
|
|
|
@ -2,13 +2,13 @@ package neofs
|
|||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Unbind struct {
|
||||
|
@ -36,30 +36,30 @@ func ParseUnbind(params []stackitem.Item) (event.Event, error) {
|
|||
// parse user
|
||||
user, err := client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get bind user")
|
||||
return nil, fmt.Errorf("could not get bind user: %w", err)
|
||||
}
|
||||
|
||||
ev.user, err = util.Uint160DecodeBytesBE(user)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert unbind user to uint160")
|
||||
return nil, fmt.Errorf("could not convert unbind user to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse keys
|
||||
unbindKeys, err := client.ArrayFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get unbind keys")
|
||||
return nil, fmt.Errorf("could not get unbind keys: %w", err)
|
||||
}
|
||||
|
||||
ev.keys = make([]*keys.PublicKey, 0, len(unbindKeys))
|
||||
for i := range unbindKeys {
|
||||
rawKey, err := client.BytesFromStackItem(unbindKeys[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get unbind public key")
|
||||
return nil, fmt.Errorf("could not get unbind public key: %w", err)
|
||||
}
|
||||
|
||||
key, err := keys.NewPublicKeyFromBytes(rawKey, elliptic.P256())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse unbind public key")
|
||||
return nil, fmt.Errorf("could not parse unbind public key: %w", err)
|
||||
}
|
||||
|
||||
ev.keys = append(ev.keys, key)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package neofs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Withdraw structure of neofs.Withdraw notification from mainnet chain.
|
||||
|
@ -38,24 +39,24 @@ func ParseWithdraw(params []stackitem.Item) (event.Event, error) {
|
|||
// parse user
|
||||
user, err := client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get withdraw user")
|
||||
return nil, fmt.Errorf("could not get withdraw user: %w", err)
|
||||
}
|
||||
|
||||
ev.user, err = util.Uint160DecodeBytesBE(user)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert withdraw user to uint160")
|
||||
return nil, fmt.Errorf("could not convert withdraw user to uint160: %w", err)
|
||||
}
|
||||
|
||||
// parse amount
|
||||
ev.amount, err = client.IntFromStackItem(params[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get withdraw amount")
|
||||
return nil, fmt.Errorf("could not get withdraw amount: %w", err)
|
||||
}
|
||||
|
||||
// parse id
|
||||
ev.id, err = client.BytesFromStackItem(params[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get withdraw id")
|
||||
return nil, fmt.Errorf("could not get withdraw id: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type AddPeer struct {
|
||||
|
@ -30,7 +31,7 @@ func ParseAddPeer(prms []stackitem.Item) (event.Event, error) {
|
|||
|
||||
ev.node, err = client.BytesFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get integer epoch number")
|
||||
return nil, fmt.Errorf("could not get integer epoch number: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// NewEpoch is a new epoch Neo:Morph event.
|
||||
|
@ -30,7 +31,7 @@ func ParseNewEpoch(prms []stackitem.Item) (event.Event, error) {
|
|||
|
||||
prmEpochNum, err := client.IntFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get integer epoch number")
|
||||
return nil, fmt.Errorf("could not get integer epoch number: %w", err)
|
||||
}
|
||||
|
||||
return NewEpoch{
|
||||
|
|
|
@ -2,6 +2,7 @@ package netmap
|
|||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
|
@ -9,7 +10,6 @@ import (
|
|||
v2netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type UpdatePeer struct {
|
||||
|
@ -41,18 +41,18 @@ func ParseUpdatePeer(prms []stackitem.Item) (event.Event, error) {
|
|||
// parse public key
|
||||
key, err := client.BytesFromStackItem(prms[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get public key")
|
||||
return nil, fmt.Errorf("could not get public key: %w", err)
|
||||
}
|
||||
|
||||
ev.publicKey, err = keys.NewPublicKeyFromBytes(key, elliptic.P256())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse public key")
|
||||
return nil, fmt.Errorf("could not parse public key: %w", err)
|
||||
}
|
||||
|
||||
// parse node status
|
||||
st, err := client.IntFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get node status")
|
||||
return nil, fmt.Errorf("could not get node status: %w", err)
|
||||
}
|
||||
|
||||
ev.status = netmap.NodeStateFromV2(v2netmap.NodeState(st))
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package event
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Parser is a function that constructs Event
|
||||
|
@ -31,7 +32,7 @@ func WrongNumberOfParameters(exp, act int) error {
|
|||
}
|
||||
|
||||
func (s wrongPrmNumber) Error() string {
|
||||
return errors.Errorf("wrong parameter count: expected %d, has %d", s.exp, s.act).Error()
|
||||
return fmt.Errorf("wrong parameter count: expected %d, has %d", s.exp, s.act).Error()
|
||||
}
|
||||
|
||||
// SetParser is an event parser setter.
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/reputation"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Put structure of reputation.reputationPut notification from
|
||||
|
@ -50,7 +51,7 @@ func ParsePut(prms []stackitem.Item) (event.Event, error) {
|
|||
// parse epoch number
|
||||
epoch, err := client.IntFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get integer epoch number")
|
||||
return nil, fmt.Errorf("could not get integer epoch number: %w", err)
|
||||
}
|
||||
|
||||
ev.epoch = uint64(epoch)
|
||||
|
@ -58,11 +59,11 @@ func ParsePut(prms []stackitem.Item) (event.Event, error) {
|
|||
// parse peer ID value
|
||||
peerID, err := client.BytesFromStackItem(prms[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get peer ID value")
|
||||
return nil, fmt.Errorf("could not get peer ID value: %w", err)
|
||||
}
|
||||
|
||||
if ln := len(peerID); ln != peerIDLength {
|
||||
return nil, errors.Errorf("peer ID is %d byte long, expected %d", ln, peerIDLength)
|
||||
return nil, fmt.Errorf("peer ID is %d byte long, expected %d", ln, peerIDLength)
|
||||
}
|
||||
|
||||
var publicKey [33]byte
|
||||
|
@ -72,12 +73,12 @@ func ParsePut(prms []stackitem.Item) (event.Event, error) {
|
|||
// parse global trust value
|
||||
rawValue, err := client.BytesFromStackItem(prms[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get global trust value")
|
||||
return nil, fmt.Errorf("could not get global trust value: %w", err)
|
||||
}
|
||||
|
||||
err = ev.value.Unmarshal(rawValue)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse global trust value")
|
||||
return nil, fmt.Errorf("could not parse global trust value: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue