[#1558] morph/event: Remove "could not" from error messages

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-12-12 14:59:49 +03:00
parent 7853dbc315
commit 91d9dc2676
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg
4 changed files with 17 additions and 17 deletions

View file

@ -111,7 +111,7 @@ type listener struct {
pool *ants.Pool pool *ants.Pool
} }
const newListenerFailMsg = "could not instantiate Listener" const newListenerFailMsg = "instantiate Listener"
var ( var (
errNilLogger = errors.New("nil logger") errNilLogger = errors.New("nil logger")
@ -195,20 +195,20 @@ func (l *listener) subscribe(errCh chan error) {
err := l.subscriber.SubscribeForNotification(hashes...) err := l.subscriber.SubscribeForNotification(hashes...)
if err != nil { if err != nil {
errCh <- fmt.Errorf("could not subscribe for notifications: %w", err) errCh <- fmt.Errorf("subscribe for notifications: %w", err)
return return
} }
if len(l.blockHandlers) > 0 { if len(l.blockHandlers) > 0 {
if err = l.subscriber.BlockNotifications(); err != nil { if err = l.subscriber.BlockNotifications(); err != nil {
errCh <- fmt.Errorf("could not subscribe for blocks: %w", err) errCh <- fmt.Errorf("subscribe for blocks: %w", err)
return return
} }
} }
if l.listenNotary { if l.listenNotary {
if err = l.subscriber.SubscribeForNotaryRequests(l.notaryMainTXSigner); err != nil { if err = l.subscriber.SubscribeForNotaryRequests(l.notaryMainTXSigner); err != nil {
errCh <- fmt.Errorf("could not subscribe for notary requests: %w", err) errCh <- fmt.Errorf("subscribe for notary requests: %w", err)
return return
} }
} }
@ -566,7 +566,7 @@ func NewListener(p ListenerParams) (Listener, error) {
// The default capacity is 0, which means "infinite". // The default capacity is 0, which means "infinite".
pool, err := ants.NewPool(p.WorkerPoolCapacity) pool, err := ants.NewPool(p.WorkerPoolCapacity)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not init worker pool: %w", err) return nil, fmt.Errorf("init worker pool: %w", err)
} }
return &listener{ return &listener{

View file

@ -10,7 +10,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
) )
var errNilPubKey = errors.New("could not parse public key: public key is nil") var errNilPubKey = errors.New("public key is nil")
func (s *UpdatePeer) setPublicKey(v []byte) (err error) { func (s *UpdatePeer) setPublicKey(v []byte) (err error) {
if v == nil { if v == nil {
@ -19,7 +19,7 @@ func (s *UpdatePeer) setPublicKey(v []byte) (err error) {
s.PubKey, err = keys.NewPublicKeyFromBytes(v, elliptic.P256()) s.PubKey, err = keys.NewPublicKeyFromBytes(v, elliptic.P256())
if err != nil { if err != nil {
return fmt.Errorf("could not parse public key: %w", err) return fmt.Errorf("parse public key: %w", err)
} }
return return

View file

@ -127,7 +127,7 @@ func (p Preparator) Prepare(nr *payload.P2PNotaryRequest) (NotaryEvent, error) {
for { for {
opCode, param, err = ctx.Next() opCode, param, err = ctx.Next()
if err != nil { if err != nil {
return nil, fmt.Errorf("could not get next opcode in script: %w", err) return nil, fmt.Errorf("get next opcode in script: %w", err)
} }
if opCode == opcode.RET { if opCode == opcode.RET {
@ -147,7 +147,7 @@ func (p Preparator) Prepare(nr *payload.P2PNotaryRequest) (NotaryEvent, error) {
// retrieve contract's script hash // retrieve contract's script hash
contractHash, err := util.Uint160DecodeBytesBE(ops[opsLen-2].param) contractHash, err := util.Uint160DecodeBytesBE(ops[opsLen-2].param)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not decode contract hash: %w", err) return nil, fmt.Errorf("decode contract hash: %w", err)
} }
// retrieve contract's method // retrieve contract's method
@ -164,7 +164,7 @@ func (p Preparator) Prepare(nr *payload.P2PNotaryRequest) (NotaryEvent, error) {
if len(args) != 0 { if len(args) != 0 {
err = p.validateParameterOpcodes(args) err = p.validateParameterOpcodes(args)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not validate arguments: %w", err) return nil, fmt.Errorf("validate arguments: %w", err)
} }
// without args packing opcodes // without args packing opcodes
@ -206,7 +206,7 @@ func (p Preparator) validateNotaryRequest(nr *payload.P2PNotaryRequest) error {
currentAlphabet, err := p.alphaKeys() currentAlphabet, err := p.alphaKeys()
if err != nil { if err != nil {
return fmt.Errorf("could not fetch Alphabet public keys: %w", err) return fmt.Errorf("fetch Alphabet public keys: %w", err)
} }
err = p.validateCosigners(ln, nr.MainTransaction.Signers, currentAlphabet) err = p.validateCosigners(ln, nr.MainTransaction.Signers, currentAlphabet)
@ -239,7 +239,7 @@ func (p Preparator) validateParameterOpcodes(ops []Op) error {
argsLen, err := IntFromOpcode(ops[l-2]) argsLen, err := IntFromOpcode(ops[l-2])
if err != nil { if err != nil {
return fmt.Errorf("could not parse argument len: %w", err) return fmt.Errorf("parse argument len: %w", err)
} }
err = validateNestedArgs(argsLen, ops[:l-2]) err = validateNestedArgs(argsLen, ops[:l-2])
@ -273,7 +273,7 @@ func validateNestedArgs(expArgLen int64, ops []Op) error {
argsLen, err := IntFromOpcode(ops[i-1]) argsLen, err := IntFromOpcode(ops[i-1])
if err != nil { if err != nil {
return fmt.Errorf("could not parse argument len: %w", err) return fmt.Errorf("parse argument len: %w", err)
} }
expArgLen += argsLen + 1 expArgLen += argsLen + 1
@ -307,7 +307,7 @@ func (p Preparator) validateExpiration(fbTX *transaction.Transaction) error {
currBlock, err := p.blockCounter.BlockCount() currBlock, err := p.blockCounter.BlockCount()
if err != nil { if err != nil {
return fmt.Errorf("could not fetch current chain height: %w", err) return fmt.Errorf("fetch current chain height: %w", err)
} }
if currBlock >= nvb.Height { if currBlock >= nvb.Height {
@ -327,7 +327,7 @@ func (p Preparator) validateCosigners(expected int, s []transaction.Signer, alph
alphaVerificationScript, err := smartcontract.CreateMultiSigRedeemScript(len(alphaKeys)*2/3+1, alphaKeys) alphaVerificationScript, err := smartcontract.CreateMultiSigRedeemScript(len(alphaKeys)*2/3+1, alphaKeys)
if err != nil { if err != nil {
return fmt.Errorf("could not get Alphabet verification script: %w", err) return fmt.Errorf("get Alphabet verification script: %w", err)
} }
if !s[1].Account.Equals(hash.Hash160(alphaVerificationScript)) { if !s[1].Account.Equals(hash.Hash160(alphaVerificationScript)) {
@ -346,7 +346,7 @@ func (p Preparator) validateWitnesses(w []transaction.Witness, alphaKeys keys.Pu
alphaVerificationScript, err := smartcontract.CreateMultiSigRedeemScript(len(alphaKeys)*2/3+1, alphaKeys) alphaVerificationScript, err := smartcontract.CreateMultiSigRedeemScript(len(alphaKeys)*2/3+1, alphaKeys)
if err != nil { if err != nil {
return fmt.Errorf("could not get Alphabet verification script: %w", err) return fmt.Errorf("get Alphabet verification script: %w", err)
} }
// the second one must be witness of the current // the second one must be witness of the current

View file

@ -26,7 +26,7 @@ func (Designate) MorphEvent() {}
func ParseDesignate(e *state.ContainedNotificationEvent) (event.Event, error) { func ParseDesignate(e *state.ContainedNotificationEvent) (event.Event, error) {
params, err := event.ParseStackArray(e) params, err := event.ParseStackArray(e)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err) return nil, fmt.Errorf("parse stack items from notify event: %w", err)
} }
if len(params) != 2 { if len(params) != 2 {