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,8 +1,9 @@
|
|||
package audit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetAuditResultArgs groups the arguments
|
||||
|
@ -35,14 +36,14 @@ func (c *Client) GetAuditResult(args GetAuditResultArgs) (*GetAuditResultValue,
|
|||
args.id,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getResultMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getResultMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.getResultMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.getResultMethod, ln)
|
||||
}
|
||||
|
||||
resultBytes, err := client.BytesFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.getResultMethod)
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.getResultMethod, err)
|
||||
}
|
||||
|
||||
return &GetAuditResultValue{
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package audit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ListResultsArgs groups the arguments
|
||||
|
@ -66,7 +67,7 @@ func (c *Client) ListAuditResults(args ListResultsArgs) (*ListResultsValues, err
|
|||
c.listResultsMethod,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listResultsMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listResultsMethod, err)
|
||||
}
|
||||
|
||||
return parseAuditResults(items, c.listResultsMethod)
|
||||
|
@ -80,7 +81,7 @@ func (c *Client) ListAuditResultsByEpoch(args ListResultsByEpochArgs) (*ListResu
|
|||
args.epoch,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByEpochResultsMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByEpochResultsMethod, err)
|
||||
}
|
||||
|
||||
return parseAuditResults(items, c.listByEpochResultsMethod)
|
||||
|
@ -95,7 +96,7 @@ func (c *Client) ListAuditResultsByCID(args ListResultsByCIDArgs) (*ListResultsV
|
|||
args.cid,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByCIDResultsMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByCIDResultsMethod, err)
|
||||
}
|
||||
|
||||
return parseAuditResults(items, c.listByCIDResultsMethod)
|
||||
|
@ -111,7 +112,7 @@ func (c *Client) ListAuditResultsByNode(args ListResultsByNodeArgs) (*ListResult
|
|||
args.nodeKey,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByNodeResultsMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByNodeResultsMethod, err)
|
||||
}
|
||||
|
||||
return parseAuditResults(items, c.listByNodeResultsMethod)
|
||||
|
@ -119,12 +120,12 @@ func (c *Client) ListAuditResultsByNode(args ListResultsByNodeArgs) (*ListResult
|
|||
|
||||
func parseAuditResults(items []stackitem.Item, method string) (*ListResultsValues, error) {
|
||||
if ln := len(items); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", method, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", method, ln)
|
||||
}
|
||||
|
||||
items, err := client.ArrayFromStackItem(items[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", method)
|
||||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", method, err)
|
||||
}
|
||||
|
||||
res := &ListResultsValues{
|
||||
|
@ -134,7 +135,7 @@ func parseAuditResults(items []stackitem.Item, method string) (*ListResultsValue
|
|||
for i := range items {
|
||||
rawRes, err := client.BytesFromStackItem(items[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", method)
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", method, err)
|
||||
}
|
||||
|
||||
res.rawResults = append(res.rawResults, rawRes)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package audit
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// PutAuditResultArgs groups the arguments
|
||||
|
@ -19,8 +19,13 @@ func (g *PutAuditResultArgs) SetRawResult(v []byte) {
|
|||
// PutAuditResult invokes the call of "put audit result" method
|
||||
// of NeoFS Audit contract.
|
||||
func (c *Client) PutAuditResult(args PutAuditResultArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
err := c.client.Invoke(
|
||||
c.putResultMethod,
|
||||
args.rawResult,
|
||||
), "could not invoke method (%s)", c.putResultMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.putResultMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package audit
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ResultID is an identity of audit result inside audit contract.
|
||||
|
@ -19,7 +21,7 @@ var errUnsupported = errors.New("unsupported structure version")
|
|||
func (w *ClientWrapper) PutAuditResult(result *auditAPI.Result) error {
|
||||
rawResult, err := result.Marshal()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not marshal audit result")
|
||||
return fmt.Errorf("could not marshal audit result: %w", err)
|
||||
}
|
||||
|
||||
args := audit.PutAuditResultArgs{}
|
||||
|
@ -121,7 +123,7 @@ func (w *ClientWrapper) GetAuditResult(id ResultID) (*auditAPI.Result, error) {
|
|||
|
||||
auditRes := auditAPI.NewResult()
|
||||
if err := auditRes.Unmarshal(value.Result()); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal audit result structure")
|
||||
return nil, fmt.Errorf("could not unmarshal audit result structure: %w", err)
|
||||
}
|
||||
|
||||
return auditRes, nil
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetBalanceOfArgs groups the arguments
|
||||
|
@ -38,14 +38,14 @@ func (c *Client) BalanceOf(args GetBalanceOfArgs) (*GetBalanceOfValues, error) {
|
|||
args.wallet,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.balanceOfMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.balanceOfMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.balanceOfMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.balanceOfMethod, ln)
|
||||
}
|
||||
|
||||
amount, err := client.BigIntFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get integer stack item from stack item (%s)", c.balanceOfMethod)
|
||||
return nil, fmt.Errorf("could not get integer stack item from stack item (%s): %w", c.balanceOfMethod, err)
|
||||
}
|
||||
|
||||
return &GetBalanceOfValues{
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// DecimalsArgs groups the arguments
|
||||
|
@ -28,14 +29,14 @@ func (c *Client) Decimals(args DecimalsArgs) (*DecimalsValues, error) {
|
|||
c.decimalsMethod,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.decimalsMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.decimalsMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.decimalsMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.decimalsMethod, ln)
|
||||
}
|
||||
|
||||
decimals, err := client.IntFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get integer stack item from stack item (%s)", c.decimalsMethod)
|
||||
return nil, fmt.Errorf("could not get integer stack item from stack item (%s): %w", c.decimalsMethod, err)
|
||||
}
|
||||
|
||||
return &DecimalsValues{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// TransferXArgs groups the arguments
|
||||
|
@ -58,11 +58,16 @@ func (c *Client) transferX(notary bool, args TransferXArgs) error {
|
|||
f = c.client.NotaryInvoke
|
||||
}
|
||||
|
||||
return errors.Wrapf(f(
|
||||
err := f(
|
||||
c.transferXMethod,
|
||||
args.sender,
|
||||
args.recipient,
|
||||
args.amount,
|
||||
args.details,
|
||||
), "could not invoke method (%s)", c.transferXMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.transferXMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Decimals decimal precision of currency transactions
|
||||
|
@ -14,7 +15,7 @@ func (w *Wrapper) Decimals() (uint32, error) {
|
|||
// invoke smart contract call
|
||||
values, err := w.client.Decimals(args)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "could not invoke smart contract")
|
||||
return 0, fmt.Errorf("could not invoke smart contract: %w", err)
|
||||
}
|
||||
|
||||
return uint32(values.Decimals()), nil
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// TransferPrm groups parameters of TransferX method.
|
||||
|
@ -30,12 +31,12 @@ func (w *Wrapper) TransferXNotary(p TransferPrm) error {
|
|||
func (w *Wrapper) transferX(notary bool, p TransferPrm) error {
|
||||
from, err := owner.ScriptHashBE(p.From)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "invalid sender")
|
||||
return fmt.Errorf("invalid sender: %w", err)
|
||||
}
|
||||
|
||||
to, err := owner.ScriptHashBE(p.To)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "invalid recipient")
|
||||
return fmt.Errorf("invalid recipient: %w", err)
|
||||
}
|
||||
|
||||
// prepare invocation arguments
|
||||
|
|
|
@ -2,6 +2,7 @@ package client
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
@ -17,7 +18,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -230,7 +230,7 @@ func (c *Client) TxHalt(h util.Uint256) (bool, error) {
|
|||
func (c *Client) NeoFSAlphabetList() (keys.PublicKeys, error) {
|
||||
list, err := c.roleList(noderoles.NeoFSAlphabet)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't get alphabet nodes role list")
|
||||
return nil, fmt.Errorf("can't get alphabet nodes role list: %w", err)
|
||||
}
|
||||
|
||||
return list, nil
|
||||
|
@ -239,7 +239,7 @@ func (c *Client) NeoFSAlphabetList() (keys.PublicKeys, error) {
|
|||
func (c *Client) roleList(r noderoles.Role) (keys.PublicKeys, error) {
|
||||
height, err := c.client.GetBlockCount()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't get chain height")
|
||||
return nil, fmt.Errorf("can't get chain height: %w", err)
|
||||
}
|
||||
|
||||
return c.client.GetDesignatedByRole(r, height)
|
||||
|
@ -285,7 +285,7 @@ func toStackParameter(value interface{}) (sc.Parameter, error) {
|
|||
|
||||
return toStackParameter(arr)
|
||||
default:
|
||||
return result, errors.Errorf("chain/client: unsupported parameter %v", value)
|
||||
return result, fmt.Errorf("chain/client: unsupported parameter %v", value)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package container
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DeleteArgs groups the arguments
|
||||
// of delete container invocation call.
|
||||
|
@ -25,9 +27,14 @@ func (p *DeleteArgs) SetSignature(v []byte) {
|
|||
// Delete invokes the call of delete container
|
||||
// method of NeoFS Container contract.
|
||||
func (c *Client) Delete(args DeleteArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
err := c.client.Invoke(
|
||||
c.deleteMethod,
|
||||
args.cid,
|
||||
args.sig,
|
||||
), "could not invoke method (%s)", c.deleteMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.deleteMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// EACLArgs groups the arguments
|
||||
|
@ -51,33 +52,33 @@ func (c *Client) EACL(args EACLArgs) (*EACLValues, error) {
|
|||
args.cid,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.eaclMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.eaclMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.eaclMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.eaclMethod, ln)
|
||||
}
|
||||
|
||||
arr, err := client.ArrayFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get item array of eACL (%s)", c.eaclMethod)
|
||||
return nil, fmt.Errorf("could not get item array of eACL (%s): %w", c.eaclMethod, err)
|
||||
}
|
||||
|
||||
if len(arr) != 3 {
|
||||
return nil, errors.Errorf("unexpected eacl stack item count (%s): %d", c.eaclMethod, len(arr))
|
||||
return nil, fmt.Errorf("unexpected eacl stack item count (%s): %d", c.eaclMethod, len(arr))
|
||||
}
|
||||
|
||||
eacl, err := client.BytesFromStackItem(arr[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array of eACL (%s)", c.eaclMethod)
|
||||
return nil, fmt.Errorf("could not get byte array of eACL (%s): %w", c.eaclMethod, err)
|
||||
}
|
||||
|
||||
sig, err := client.BytesFromStackItem(arr[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array of eACL signature (%s)", c.eaclMethod)
|
||||
return nil, fmt.Errorf("could not get byte array of eACL signature (%s): %w", c.eaclMethod, err)
|
||||
}
|
||||
|
||||
pub, err := client.BytesFromStackItem(arr[2])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array of eACL public key (%s)", c.eaclMethod)
|
||||
return nil, fmt.Errorf("could not get byte array of eACL public key (%s): %w", c.eaclMethod, err)
|
||||
}
|
||||
|
||||
return &EACLValues{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package container
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SetEACLArgs groups the arguments
|
||||
// of set eACL invocation call.
|
||||
|
@ -25,9 +27,14 @@ func (p *SetEACLArgs) SetSignature(v []byte) {
|
|||
// SetEACL invokes the call of set eACL method
|
||||
// of NeoFS Container contract.
|
||||
func (c *Client) SetEACL(args SetEACLArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
err := c.client.Invoke(
|
||||
c.setEACLMethod,
|
||||
args.eacl,
|
||||
args.sig,
|
||||
), "could not invoke method (%s)", c.setEACLMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.setEACLMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type StartEstimation struct {
|
||||
|
@ -21,29 +21,29 @@ func (e *StopEstimation) SetEpoch(v int64) {
|
|||
}
|
||||
|
||||
func (c *Client) StartEstimation(args StartEstimation) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
c.startEstimation,
|
||||
args.epoch,
|
||||
), "could not invoke method (%s)", c.startEstimation)
|
||||
if err := c.client.Invoke(c.startEstimation, args.epoch); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.startEstimation, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) StartEstimationNotary(args StartEstimation) error {
|
||||
return errors.Wrapf(c.client.NotaryInvoke(
|
||||
c.startEstimation,
|
||||
args.epoch,
|
||||
), "could not invoke method (%s)", c.startEstimation)
|
||||
if err := c.client.NotaryInvoke(c.startEstimation, args.epoch); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.startEstimation, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) StopEstimation(args StopEstimation) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
c.stopEstimation,
|
||||
args.epoch,
|
||||
), "could not invoke method (%s)", c.stopEstimation)
|
||||
if err := c.client.Invoke(c.stopEstimation, args.epoch); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.stopEstimation, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) StopEstimationNotary(args StopEstimation) error {
|
||||
return errors.Wrapf(c.client.NotaryInvoke(
|
||||
c.stopEstimation,
|
||||
args.epoch,
|
||||
), "could not invoke method (%s)", c.stopEstimation)
|
||||
if err := c.client.NotaryInvoke(c.stopEstimation, args.epoch); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.stopEstimation, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetArgs groups the arguments
|
||||
|
@ -37,14 +38,14 @@ func (c *Client) Get(args GetArgs) (*GetValues, error) {
|
|||
args.cid,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.getMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.getMethod, ln)
|
||||
}
|
||||
|
||||
cnrBytes, err := client.BytesFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.getMethod)
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.getMethod, err)
|
||||
}
|
||||
|
||||
return &GetValues{
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ListArgs groups the arguments
|
||||
|
@ -41,14 +42,14 @@ func (c *Client) List(args ListArgs) (*ListValues, error) {
|
|||
invokeArgs...,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.listMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.listMethod, ln)
|
||||
}
|
||||
|
||||
prms, err = client.ArrayFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", c.listMethod)
|
||||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", c.listMethod, err)
|
||||
}
|
||||
|
||||
res := &ListValues{
|
||||
|
@ -58,7 +59,7 @@ func (c *Client) List(args ListArgs) (*ListValues, error) {
|
|||
for i := range prms {
|
||||
cid, err := client.BytesFromStackItem(prms[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.listMethod)
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.listMethod, err)
|
||||
}
|
||||
|
||||
res.cidList = append(res.cidList, cid)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// PutSizeArgs groups the arguments
|
||||
|
@ -43,13 +44,18 @@ func (p *PutSizeArgs) SetReporterKey(v []byte) {
|
|||
// Put invokes the call of put container method
|
||||
// of NeoFS Container contract.
|
||||
func (c *Client) PutSize(args PutSizeArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
err := c.client.Invoke(
|
||||
c.putSizeMethod,
|
||||
args.epoch,
|
||||
args.cid,
|
||||
args.size,
|
||||
args.reporterKey,
|
||||
), "could not invoke method (%s)", c.putSizeMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.putSizeMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListSizesArgs groups the arguments
|
||||
|
@ -84,14 +90,14 @@ func (c *Client) ListSizes(args ListSizesArgs) (*ListSizesValues, error) {
|
|||
args.epoch,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listSizesMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listSizesMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.listSizesMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.listSizesMethod, ln)
|
||||
}
|
||||
|
||||
prms, err = client.ArrayFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", c.listSizesMethod)
|
||||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", c.listSizesMethod, err)
|
||||
}
|
||||
|
||||
res := &ListSizesValues{
|
||||
|
@ -101,7 +107,7 @@ func (c *Client) ListSizes(args ListSizesArgs) (*ListSizesValues, error) {
|
|||
for i := range prms {
|
||||
id, err := client.BytesFromStackItem(prms[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get ID byte array from stack item (%s)", c.listSizesMethod)
|
||||
return nil, fmt.Errorf("could not get ID byte array from stack item (%s): %w", c.listSizesMethod, err)
|
||||
}
|
||||
|
||||
res.ids = append(res.ids, id)
|
||||
|
@ -152,28 +158,28 @@ func (c *Client) GetContainerSize(args GetSizeArgs) (*GetSizeValues, error) {
|
|||
args.id,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getSizeMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.getSizeMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.getSizeMethod, ln)
|
||||
}
|
||||
|
||||
prms, err = client.ArrayFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get stack items of estimation fields from stack item (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("could not get stack items of estimation fields from stack item (%s): %w", c.getSizeMethod, err)
|
||||
} else if ln := len(prms); ln != 2 {
|
||||
return nil, errors.Errorf("unexpected stack item count of estimations fields (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("unexpected stack item count of estimations fields (%s)", c.getSizeMethod)
|
||||
}
|
||||
|
||||
es := Estimations{}
|
||||
|
||||
es.ContainerID, err = client.BytesFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get container ID byte array from stack item (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("could not get container ID byte array from stack item (%s): %w", c.getSizeMethod, err)
|
||||
}
|
||||
|
||||
prms, err = client.ArrayFromStackItem(prms[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get estimation list array from stack item (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("could not get estimation list array from stack item (%s): %w", c.getSizeMethod, err)
|
||||
}
|
||||
|
||||
es.Estimations = make([]Estimation, 0, len(prms))
|
||||
|
@ -181,21 +187,21 @@ func (c *Client) GetContainerSize(args GetSizeArgs) (*GetSizeValues, error) {
|
|||
for i := range prms {
|
||||
arr, err := client.ArrayFromStackItem(prms[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get estimation struct from stack item (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("could not get estimation struct from stack item (%s): %w", c.getSizeMethod, err)
|
||||
} else if ln := len(arr); ln != 2 {
|
||||
return nil, errors.Errorf("unexpected stack item count of estimation fields (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("unexpected stack item count of estimation fields (%s)", c.getSizeMethod)
|
||||
}
|
||||
|
||||
e := Estimation{}
|
||||
|
||||
e.Reporter, err = client.BytesFromStackItem(arr[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get reporter byte array from stack item (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("could not get reporter byte array from stack item (%s): %w", c.getSizeMethod, err)
|
||||
}
|
||||
|
||||
e.Size, err = client.IntFromStackItem(arr[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get estimation size from stack item (%s)", c.getSizeMethod)
|
||||
return nil, fmt.Errorf("could not get estimation size from stack item (%s): %w", c.getSizeMethod, err)
|
||||
}
|
||||
|
||||
es.Estimations = append(es.Estimations, e)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// PutArgs groups the arguments
|
||||
|
@ -35,10 +35,15 @@ func (p *PutArgs) SetSignature(v []byte) {
|
|||
// Put invokes the call of put container method
|
||||
// of NeoFS Container contract.
|
||||
func (c *Client) Put(args PutArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
err := c.client.Invoke(
|
||||
c.putMethod,
|
||||
args.cnr,
|
||||
args.sig,
|
||||
args.publicKey,
|
||||
), "could not invoke method (%s)", c.putMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@ package wrapper
|
|||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -34,7 +35,7 @@ func (w *Wrapper) Put(cnr *container.Container, pubKey, signature []byte) (*cont
|
|||
|
||||
data, err := cnr.Marshal()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't marshal container")
|
||||
return nil, fmt.Errorf("can't marshal container: %w", err)
|
||||
}
|
||||
|
||||
id.SetSHA256(sha256.Sum256(data))
|
||||
|
@ -79,7 +80,7 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) {
|
|||
cnr := container.New()
|
||||
if err := cnr.Unmarshal(rpcAnswer.Container()); err != nil {
|
||||
// use other major version if there any
|
||||
return nil, errors.Wrap(err, "can't unmarshal container")
|
||||
return nil, fmt.Errorf("can't unmarshal container: %w", err)
|
||||
}
|
||||
|
||||
return cnr, nil
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetEACL reads the extended ACL table from NeoFS system
|
||||
|
@ -65,7 +66,7 @@ func (w *Wrapper) PutEACL(table *eacl.Table, signature []byte) error {
|
|||
|
||||
data, err := table.Marshal()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "can't marshal eacl table")
|
||||
return fmt.Errorf("can't marshal eacl table: %w", err)
|
||||
}
|
||||
|
||||
args.SetEACL(data)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// AddPeerArgs groups the arguments
|
||||
|
@ -18,10 +18,8 @@ func (a *AddPeerArgs) SetInfo(v []byte) {
|
|||
// AddPeer invokes the call of add peer method
|
||||
// of NeoFS Netmap contract.
|
||||
func (c *Client) AddPeer(args AddPeerArgs) error {
|
||||
info := args.info
|
||||
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
c.addPeerMethod,
|
||||
info,
|
||||
), "could not invoke method (%s)", c.addPeerMethod)
|
||||
if err := c.client.Invoke(c.addPeerMethod, args.info); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.addPeerMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ConfigArgs groups the arguments
|
||||
|
@ -36,19 +37,18 @@ func (c *Client) Config(args ConfigArgs, assert func(stackitem.Item) (interface{
|
|||
args.key,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err,
|
||||
"could not perform test invocation (%s)",
|
||||
c.configMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
|
||||
c.configMethod, err)
|
||||
}
|
||||
|
||||
if ln := len(items); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d",
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d",
|
||||
c.configMethod, ln)
|
||||
}
|
||||
|
||||
val, err := assert(items[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "value type assertion failed")
|
||||
return nil, fmt.Errorf("value type assertion failed: %w", err)
|
||||
}
|
||||
|
||||
return &ConfigValues{
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// EpochArgs groups the arguments
|
||||
|
@ -28,19 +29,18 @@ func (c *Client) Epoch(_ EpochArgs) (*EpochValues, error) {
|
|||
c.epochMethod,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err,
|
||||
"could not perform test invocation (%s)",
|
||||
c.epochMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
|
||||
c.epochMethod, err)
|
||||
}
|
||||
|
||||
if ln := len(items); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d",
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d",
|
||||
c.epochMethod, ln)
|
||||
}
|
||||
|
||||
num, err := client.IntFromStackItem(items[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get number from stack item (%s)", c.epochMethod)
|
||||
return nil, fmt.Errorf("could not get number from stack item (%s): %w", c.epochMethod, err)
|
||||
}
|
||||
|
||||
return &EpochValues{
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetNetMapArgs groups the arguments
|
||||
|
@ -61,9 +62,8 @@ func (c *Client) NetMap(_ GetNetMapArgs) (*GetNetMapValues, error) {
|
|||
c.netMapMethod,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err,
|
||||
"could not perform test invocation (%s)",
|
||||
c.netMapMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
|
||||
c.netMapMethod, err)
|
||||
}
|
||||
|
||||
return peersFromStackItems(prms, c.netMapMethod)
|
||||
|
@ -78,9 +78,8 @@ func (c *Client) Snapshot(a GetSnapshotArgs) (*GetNetMapValues, error) {
|
|||
int64(a.diff),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err,
|
||||
"could not perform test invocation (%s)",
|
||||
c.netMapMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
|
||||
c.netMapMethod, err)
|
||||
}
|
||||
|
||||
return peersFromStackItems(prms, c.snapshotMethod)
|
||||
|
@ -94,9 +93,8 @@ func (c *Client) EpochSnapshot(args EpochSnapshotArgs) (*EpochSnapshotValues, er
|
|||
int64(args.epoch),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err,
|
||||
"could not perform test invocation (%s)",
|
||||
c.epochSnapshotMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
|
||||
c.epochSnapshotMethod, err)
|
||||
}
|
||||
|
||||
nmVals, err := peersFromStackItems(prms, c.epochSnapshotMethod)
|
||||
|
@ -111,15 +109,14 @@ func (c *Client) EpochSnapshot(args EpochSnapshotArgs) (*EpochSnapshotValues, er
|
|||
|
||||
func peersFromStackItems(stack []stackitem.Item, method string) (*GetNetMapValues, error) {
|
||||
if ln := len(stack); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d",
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d",
|
||||
method, ln)
|
||||
}
|
||||
|
||||
peers, err := client.ArrayFromStackItem(stack[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err,
|
||||
"could not get stack item array from stack item (%s)",
|
||||
method)
|
||||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w",
|
||||
method, err)
|
||||
}
|
||||
|
||||
res := &GetNetMapValues{
|
||||
|
@ -129,8 +126,7 @@ func peersFromStackItems(stack []stackitem.Item, method string) (*GetNetMapValue
|
|||
for i := range peers {
|
||||
peer, err := peerInfoFromStackItem(peers[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err,
|
||||
"could not parse stack item (Peer #%d)", i)
|
||||
return nil, fmt.Errorf("could not parse stack item (Peer #%d): %w", i, err)
|
||||
}
|
||||
|
||||
res.peers = append(res.peers, peer)
|
||||
|
@ -142,9 +138,9 @@ func peersFromStackItems(stack []stackitem.Item, method string) (*GetNetMapValue
|
|||
func peerInfoFromStackItem(prm stackitem.Item) ([]byte, error) {
|
||||
prms, err := client.ArrayFromStackItem(prm)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get stack item array (PeerInfo)")
|
||||
return nil, fmt.Errorf("could not get stack item array (PeerInfo): %w", err)
|
||||
} else if ln := len(prms); ln != nodeInfoFixedPrmNumber {
|
||||
return nil, errors.Errorf("unexpected stack item count (PeerInfo): expected %d, has %d", 1, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (PeerInfo): expected %d, has %d", 1, ln)
|
||||
}
|
||||
|
||||
return client.BytesFromStackItem(prms[0])
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package netmap
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// NewEpochArgs groups the arguments
|
||||
// of new epoch invocation call.
|
||||
|
@ -16,8 +18,8 @@ func (a *NewEpochArgs) SetEpochNumber(v int64) {
|
|||
// NewEpoch invokes the call of new epoch method
|
||||
// of NeoFS Netmap contract.
|
||||
func (c *Client) NewEpoch(args NewEpochArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
c.addPeerMethod,
|
||||
args.number,
|
||||
), "could not invoke method (%s)", c.newEpochMethod)
|
||||
if err := c.client.Invoke(c.addPeerMethod, args.number); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.newEpochMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// UpdateStateArgs groups the arguments
|
||||
|
@ -26,9 +26,15 @@ func (u *UpdateStateArgs) SetState(v int64) {
|
|||
// UpdateState invokes the call of update state method
|
||||
// of NeoFS Netmap contract.
|
||||
func (c *Client) UpdateState(args UpdateStateArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
err := c.client.Invoke(
|
||||
c.updateStateMethod,
|
||||
args.state,
|
||||
args.key,
|
||||
), "could not invoke method (%s)", c.updateStateMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.updateStateMethod, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// AddPeer registers peer in NeoFS network through
|
||||
|
@ -20,8 +22,8 @@ func (w *Wrapper) AddPeer(nodeInfo *netmap.NodeInfo) error {
|
|||
args := netmap.AddPeerArgs{}
|
||||
args.SetInfo(rawNodeInfo)
|
||||
|
||||
return errors.Wrap(
|
||||
w.client.AddPeer(args),
|
||||
"could not invoke smart contract",
|
||||
)
|
||||
if err := w.client.AddPeer(args); err != nil {
|
||||
return fmt.Errorf("could not invoke smart contract: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -24,7 +24,7 @@ const (
|
|||
func (w *Wrapper) MaxObjectSize() (uint64, error) {
|
||||
objectSize, err := w.readUInt64Config(maxObjectSizeConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get epoch number", w)
|
||||
return 0, fmt.Errorf("(%T) could not get epoch number: %w", w, err)
|
||||
}
|
||||
|
||||
return objectSize, nil
|
||||
|
@ -35,7 +35,7 @@ func (w *Wrapper) MaxObjectSize() (uint64, error) {
|
|||
func (w *Wrapper) BasicIncomeRate() (uint64, error) {
|
||||
rate, err := w.readUInt64Config(basicIncomeRateConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get basic income rate", w)
|
||||
return 0, fmt.Errorf("(%T) could not get basic income rate: %w", w, err)
|
||||
}
|
||||
|
||||
return rate, nil
|
||||
|
@ -46,7 +46,7 @@ func (w *Wrapper) BasicIncomeRate() (uint64, error) {
|
|||
func (w *Wrapper) AuditFee() (uint64, error) {
|
||||
fee, err := w.readUInt64Config(auditFeeConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get audit fee", w)
|
||||
return 0, fmt.Errorf("(%T) could not get audit fee: %w", w, err)
|
||||
}
|
||||
|
||||
return fee, nil
|
||||
|
@ -56,7 +56,7 @@ func (w *Wrapper) AuditFee() (uint64, error) {
|
|||
func (w *Wrapper) EpochDuration() (uint64, error) {
|
||||
epochDuration, err := w.readUInt64Config(epochDurationConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get epoch duration", w)
|
||||
return 0, fmt.Errorf("(%T) could not get epoch duration: %w", w, err)
|
||||
}
|
||||
|
||||
return epochDuration, nil
|
||||
|
@ -67,7 +67,7 @@ func (w *Wrapper) EpochDuration() (uint64, error) {
|
|||
func (w *Wrapper) ContainerFee() (uint64, error) {
|
||||
fee, err := w.readUInt64Config(containerFeeConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get container fee", w)
|
||||
return 0, fmt.Errorf("(%T) could not get container fee: %w", w, err)
|
||||
}
|
||||
|
||||
return fee, nil
|
||||
|
@ -78,7 +78,7 @@ func (w *Wrapper) ContainerFee() (uint64, error) {
|
|||
func (w *Wrapper) EigenTrustIterations() (uint64, error) {
|
||||
iterations, err := w.readUInt64Config(etIterationsConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get eigen trust iterations", w)
|
||||
return 0, fmt.Errorf("(%T) could not get eigen trust iterations: %w", w, err)
|
||||
}
|
||||
|
||||
return iterations, nil
|
||||
|
@ -89,7 +89,7 @@ func (w *Wrapper) EigenTrustIterations() (uint64, error) {
|
|||
func (w *Wrapper) EigenTrustAlpha() (float64, error) {
|
||||
strAlpha, err := w.readStringConfig(etAlphaConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get eigen trust alpha", w)
|
||||
return 0, fmt.Errorf("(%T) could not get eigen trust alpha: %w", w, err)
|
||||
}
|
||||
|
||||
return strconv.ParseFloat(strAlpha, 64)
|
||||
|
@ -100,7 +100,7 @@ func (w *Wrapper) EigenTrustAlpha() (float64, error) {
|
|||
func (w *Wrapper) InnerRingCandidateFee() (uint64, error) {
|
||||
fee, err := w.readUInt64Config(irCandidateFeeConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get inner ring candidate fee", w)
|
||||
return 0, fmt.Errorf("(%T) could not get inner ring candidate fee: %w", w, err)
|
||||
}
|
||||
|
||||
return fee, nil
|
||||
|
@ -111,7 +111,7 @@ func (w *Wrapper) InnerRingCandidateFee() (uint64, error) {
|
|||
func (w *Wrapper) WithdrawFee() (uint64, error) {
|
||||
fee, err := w.readUInt64Config(withdrawFeeConfig)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get withdraw fee", w)
|
||||
return 0, fmt.Errorf("(%T) could not get withdraw fee: %w", w, err)
|
||||
}
|
||||
|
||||
return fee, nil
|
||||
|
@ -130,7 +130,7 @@ func (w *Wrapper) readUInt64Config(key string) (uint64, error) {
|
|||
|
||||
numeric, ok := v.(int64)
|
||||
if !ok {
|
||||
return 0, errors.Errorf("(%T) invalid value type %T", w, v)
|
||||
return 0, fmt.Errorf("(%T) invalid value type %T", w, v)
|
||||
}
|
||||
|
||||
return uint64(numeric), nil
|
||||
|
@ -149,7 +149,7 @@ func (w *Wrapper) readStringConfig(key string) (string, error) {
|
|||
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return "", errors.Errorf("(%T) invalid value type %T", w, v)
|
||||
return "", fmt.Errorf("(%T) invalid value type %T", w, v)
|
||||
}
|
||||
|
||||
return str, nil
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Epoch receives number of current NeoFS epoch
|
||||
|
@ -12,7 +13,7 @@ func (w *Wrapper) Epoch() (uint64, error) {
|
|||
|
||||
vals, err := w.client.Epoch(args)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "(%T) could not get epoch number", w)
|
||||
return 0, fmt.Errorf("(%T) could not get epoch number: %w", w, err)
|
||||
}
|
||||
|
||||
return uint64(vals.Number()), nil
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetNetMap receives information list about storage nodes
|
||||
|
@ -43,7 +44,7 @@ func unmarshalNetmap(rawPeers [][]byte) (*netmap.Netmap, error) {
|
|||
for _, peer := range rawPeers {
|
||||
nodeInfo := netmap.NewNodeInfo()
|
||||
if err := nodeInfo.Unmarshal(peer); err != nil {
|
||||
return nil, errors.Wrap(err, "can't unmarshal peer info")
|
||||
return nil, fmt.Errorf("can't unmarshal peer info: %w", err)
|
||||
}
|
||||
|
||||
infos = append(infos, *nodeInfo)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// UpdatePeerState changes peer status through Netmap contract
|
||||
|
@ -14,10 +15,8 @@ func (w *Wrapper) UpdatePeerState(key []byte, state netmap.NodeState) error {
|
|||
args.SetState(int64(state.ToV2()))
|
||||
|
||||
// invoke smart contract call
|
||||
//
|
||||
// Note: errors.Wrap returns nil on nil error arg.
|
||||
return errors.Wrap(
|
||||
w.client.UpdateState(args),
|
||||
"could not invoke smart contract",
|
||||
)
|
||||
if err := w.client.UpdateState(args); err != nil {
|
||||
return fmt.Errorf("could not invoke smart contract: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||
|
@ -13,7 +15,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -74,7 +75,7 @@ func (c *Client) EnableNotarySupport(proxy util.Uint160, opts ...NotaryOption) e
|
|||
|
||||
notaryContract, err := c.client.GetNativeContractHash(nativenames.Notary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "can't get notary contract script hash")
|
||||
return fmt.Errorf("can't get notary contract script hash: %w", err)
|
||||
}
|
||||
|
||||
c.notary = ¬ary{
|
||||
|
@ -110,7 +111,7 @@ func (c *Client) DepositNotary(amount fixedn.Fixed8, delta uint32) (util.Uint256
|
|||
|
||||
bc, err := c.client.GetBlockCount()
|
||||
if err != nil {
|
||||
return util.Uint256{}, errors.Wrap(err, "can't get blockchain height")
|
||||
return util.Uint256{}, fmt.Errorf("can't get blockchain height: %w", err)
|
||||
}
|
||||
|
||||
txHash, err := c.client.TransferNEP17(
|
||||
|
@ -123,7 +124,7 @@ func (c *Client) DepositNotary(amount fixedn.Fixed8, delta uint32) (util.Uint256
|
|||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
return util.Uint256{}, errors.Wrap(err, "can't make notary deposit")
|
||||
return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err)
|
||||
}
|
||||
|
||||
c.logger.Debug("notary deposit invoke",
|
||||
|
@ -148,16 +149,16 @@ func (c *Client) GetNotaryDeposit() (int64, error) {
|
|||
|
||||
items, err := c.TestInvoke(c.notary.notary, notaryBalanceOfMethod, sh)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, notaryBalanceErrMsg)
|
||||
return 0, fmt.Errorf("%v: %w", notaryBalanceErrMsg, err)
|
||||
}
|
||||
|
||||
if len(items) != 1 {
|
||||
return 0, errors.Wrap(errUnexpectedItems, notaryBalanceErrMsg)
|
||||
return 0, fmt.Errorf("%v: %w", notaryBalanceErrMsg, errUnexpectedItems)
|
||||
}
|
||||
|
||||
bigIntDeposit, err := items[0].TryInteger()
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, notaryBalanceErrMsg)
|
||||
return 0, fmt.Errorf("%v: %w", notaryBalanceErrMsg, err)
|
||||
}
|
||||
|
||||
return bigIntDeposit.Int64(), nil
|
||||
|
@ -328,7 +329,7 @@ func (c *Client) notaryCosigners(ir []*keys.PublicKey, committee bool) ([]transa
|
|||
|
||||
multisigScript, err := sc.CreateMultiSigRedeemScript(m, ir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't create ir multisig redeem script")
|
||||
return nil, fmt.Errorf("can't create ir multisig redeem script: %w", err)
|
||||
}
|
||||
|
||||
s = append(s, transaction.Signer{
|
||||
|
@ -412,7 +413,7 @@ func (c *Client) notaryMultisigAccount(ir []*keys.PublicKey, committee bool) (*w
|
|||
|
||||
err := multisigAccount.ConvertMultisig(m, ir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't make inner ring multisig wallet")
|
||||
return nil, fmt.Errorf("can't make inner ring multisig wallet: %w", err)
|
||||
}
|
||||
|
||||
return multisigAccount, nil
|
||||
|
@ -421,7 +422,7 @@ func (c *Client) notaryMultisigAccount(ir []*keys.PublicKey, committee bool) (*w
|
|||
func (c *Client) notaryTxValidationLimit() (uint32, error) {
|
||||
bc, err := c.client.GetBlockCount()
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "can't get current blockchain height")
|
||||
return 0, fmt.Errorf("can't get current blockchain height: %w", err)
|
||||
}
|
||||
|
||||
min := bc + c.notary.txValidTime
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetArgs groups the arguments of "get reputation value" test invocation.
|
||||
|
@ -52,7 +53,7 @@ func (c *Client) Get(args GetArgs) (*GetResult, error) {
|
|||
args.peerID,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getMethod, err)
|
||||
}
|
||||
|
||||
return parseReputations(prms, c.getMethod)
|
||||
|
@ -66,7 +67,7 @@ func (c *Client) GetByID(args GetByIDArgs) (*GetResult, error) {
|
|||
args.id,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.getByIDMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.getByIDMethod, err)
|
||||
}
|
||||
|
||||
return parseReputations(prms, c.getByIDMethod)
|
||||
|
@ -74,12 +75,12 @@ func (c *Client) GetByID(args GetByIDArgs) (*GetResult, error) {
|
|||
|
||||
func parseReputations(items []stackitem.Item, method string) (*GetResult, error) {
|
||||
if ln := len(items); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", method, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", method, ln)
|
||||
}
|
||||
|
||||
items, err := client.ArrayFromStackItem(items[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", method)
|
||||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", method, err)
|
||||
}
|
||||
|
||||
res := &GetResult{
|
||||
|
@ -89,7 +90,7 @@ func parseReputations(items []stackitem.Item, method string) (*GetResult, error)
|
|||
for i := range items {
|
||||
rawReputation, err := client.BytesFromStackItem(items[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", method)
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", method, err)
|
||||
}
|
||||
|
||||
res.reputations = append(res.reputations, rawReputation)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ListByEpochArgs groups the arguments of
|
||||
|
@ -35,14 +36,14 @@ func (c *Client) ListByEpoch(args ListByEpochArgs) (*ListByEpochResult, error) {
|
|||
int64(args.epoch),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.listByEpochMethod)
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", c.listByEpochMethod, err)
|
||||
} else if ln := len(prms); ln != 1 {
|
||||
return nil, errors.Errorf("unexpected stack item count (%s): %d", c.listByEpochMethod, ln)
|
||||
return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.listByEpochMethod, ln)
|
||||
}
|
||||
|
||||
items, err := client.ArrayFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", c.listByEpochMethod)
|
||||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", c.listByEpochMethod, err)
|
||||
}
|
||||
|
||||
res := &ListByEpochResult{
|
||||
|
@ -52,7 +53,7 @@ func (c *Client) ListByEpoch(args ListByEpochArgs) (*ListByEpochResult, error) {
|
|||
for i := range items {
|
||||
rawReputation, err := client.BytesFromStackItem(items[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get byte array from stack item (%s)", c.listByEpochMethod)
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.listByEpochMethod, err)
|
||||
}
|
||||
|
||||
res.ids = append(res.ids, rawReputation)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// PutArgs groups the arguments of "put reputation value" invocation call.
|
||||
|
@ -28,21 +28,31 @@ func (p *PutArgs) SetValue(v []byte) {
|
|||
|
||||
// Put invokes direct call of "put reputation value" method of reputation contract.
|
||||
func (c *Client) Put(args PutArgs) error {
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
err := c.client.Invoke(
|
||||
c.putMethod,
|
||||
int64(args.epoch),
|
||||
args.peerID,
|
||||
args.value,
|
||||
), "could not invoke method (%s)", c.putMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PutViaNotary invokes notary call of "put reputation value" method of
|
||||
// reputation contract.
|
||||
func (c *Client) PutViaNotary(args PutArgs) error {
|
||||
return errors.Wrapf(c.client.NotaryInvoke(
|
||||
err := c.client.NotaryInvoke(
|
||||
c.putMethod,
|
||||
int64(args.epoch),
|
||||
args.peerID,
|
||||
args.value,
|
||||
), "could not invoke method (%s)", c.putMethod)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/reputation"
|
||||
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -83,7 +84,7 @@ func parseGetResult(data *reputationClient.GetResult) (*GetResult, error) {
|
|||
|
||||
err := r.Unmarshal(rawReputations[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't unmarshal global trust value")
|
||||
return nil, fmt.Errorf("can't unmarshal global trust value: %w", err)
|
||||
}
|
||||
|
||||
reputations = append(reputations, r)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/reputation"
|
||||
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -56,7 +57,7 @@ func preparePutArgs(v PutArgs) (reputationClient.PutArgs, error) {
|
|||
|
||||
data, err := v.value.Marshal()
|
||||
if err != nil {
|
||||
return args, errors.Wrap(err, "can't marshal global trust value")
|
||||
return args, fmt.Errorf("can't marshal global trust value: %w", err)
|
||||
}
|
||||
|
||||
args.SetEpoch(v.epoch)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -19,7 +19,7 @@ func BoolFromStackItem(param stackitem.Item) (bool, error) {
|
|||
case stackitem.BooleanT, stackitem.IntegerT, stackitem.ByteArrayT:
|
||||
return param.TryBool()
|
||||
default:
|
||||
return false, errors.Errorf("chain/client: %s is not a bool type", param.Type())
|
||||
return false, fmt.Errorf("chain/client: %s is not a bool type", param.Type())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ func IntFromStackItem(param stackitem.Item) (int64, error) {
|
|||
|
||||
return i.Int64(), nil
|
||||
default:
|
||||
return 0, errors.Errorf("chain/client: %s is not an integer type", param.Type())
|
||||
return 0, fmt.Errorf("chain/client: %s is not an integer type", param.Type())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func BytesFromStackItem(param stackitem.Item) ([]byte, error) {
|
|||
case stackitem.IntegerT:
|
||||
n, err := param.TryInteger()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't parse integer bytes")
|
||||
return nil, fmt.Errorf("can't parse integer bytes: %w", err)
|
||||
}
|
||||
|
||||
return n.Bytes(), nil
|
||||
|
@ -61,7 +61,7 @@ func BytesFromStackItem(param stackitem.Item) ([]byte, error) {
|
|||
}
|
||||
fallthrough
|
||||
default:
|
||||
return nil, errors.Errorf("chain/client: %s is not a byte array type", param.Type())
|
||||
return nil, fmt.Errorf("chain/client: %s is not a byte array type", param.Type())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,19 +75,19 @@ func ArrayFromStackItem(param stackitem.Item) ([]stackitem.Item, error) {
|
|||
case stackitem.ArrayT, stackitem.StructT:
|
||||
items, ok := param.Value().([]stackitem.Item)
|
||||
if !ok {
|
||||
return nil, errors.Errorf("chain/client: can't convert %T to parameter slice", param.Value())
|
||||
return nil, fmt.Errorf("chain/client: can't convert %T to parameter slice", param.Value())
|
||||
}
|
||||
|
||||
return items, nil
|
||||
default:
|
||||
return nil, errors.Errorf("chain/client: %s is not an array type", param.Type())
|
||||
return nil, fmt.Errorf("chain/client: %s is not an array type", param.Type())
|
||||
}
|
||||
}
|
||||
|
||||
// StringFromStackItem receives string value from the value of a smart contract parameter.
|
||||
func StringFromStackItem(param stackitem.Item) (string, error) {
|
||||
if param.Type() != stackitem.ByteArrayT {
|
||||
return "", errors.Errorf("chain/client: %s is not an string type", param.Type())
|
||||
return "", fmt.Errorf("chain/client: %s is not an string type", param.Type())
|
||||
}
|
||||
|
||||
return stackitem.ToString(param)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,6 +2,8 @@ package subscriber
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -10,7 +12,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -105,7 +106,7 @@ func (s *subscriber) Close() {
|
|||
|
||||
func (s *subscriber) BlockNotifications() (<-chan *block.Block, error) {
|
||||
if _, err := s.client.SubscribeForNewBlocks(nil); err != nil {
|
||||
return nil, errors.Wrap(err, "could not subscribe for new block events")
|
||||
return nil, fmt.Errorf("could not subscribe for new block events: %w", err)
|
||||
}
|
||||
|
||||
return s.blockChan, nil
|
||||
|
@ -168,7 +169,7 @@ func New(ctx context.Context, p *Params) (Subscriber, error) {
|
|||
}
|
||||
|
||||
if err := wsClient.Init(); err != nil {
|
||||
return nil, errors.Wrap(err, "could not init ws client")
|
||||
return nil, fmt.Errorf("could not init ws client: %w", err)
|
||||
}
|
||||
|
||||
sub := &subscriber{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue