mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 23:33:37 +00:00
network: specify error message
For better user experience.
This commit is contained in:
parent
717591afe8
commit
9f6fba5926
3 changed files with 32 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
package network
|
||||
|
||||
//go:generate stringer -type=RelayReason -output=relay_reason_string.go
|
||||
|
||||
// RelayReason is the type which describes the different relay outcome.
|
||||
type RelayReason uint8
|
||||
|
||||
|
|
29
pkg/network/relay_reason_string.go
Normal file
29
pkg/network/relay_reason_string.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Code generated by "stringer -type=RelayReason -output=relay_reason_string.go"; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
import "strconv"
|
||||
|
||||
func _() {
|
||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||
// Re-run the stringer command to generate them again.
|
||||
var x [1]struct{}
|
||||
_ = x[RelaySucceed-0]
|
||||
_ = x[RelayAlreadyExists-1]
|
||||
_ = x[RelayOutOfMemory-2]
|
||||
_ = x[RelayUnableToVerify-3]
|
||||
_ = x[RelayInvalid-4]
|
||||
_ = x[RelayPolicyFail-5]
|
||||
_ = x[RelayUnknown-6]
|
||||
}
|
||||
|
||||
const _RelayReason_name = "RelaySucceedRelayAlreadyExistsRelayOutOfMemoryRelayUnableToVerifyRelayInvalidRelayPolicyFailRelayUnknown"
|
||||
|
||||
var _RelayReason_index = [...]uint8{0, 12, 30, 46, 65, 77, 92, 104}
|
||||
|
||||
func (i RelayReason) String() string {
|
||||
if i >= RelayReason(len(_RelayReason_index)-1) {
|
||||
return "RelayReason(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _RelayReason_name[_RelayReason_index[i]:_RelayReason_index[i+1]]
|
||||
}
|
|
@ -154,7 +154,7 @@ func newServerFromConstructors(config ServerConfig, chain blockchainer.Blockchai
|
|||
n, err := notary.NewNotary(cfg, s.notaryRequestPool, func(tx *transaction.Transaction) error {
|
||||
r := s.RelayTxn(tx)
|
||||
if r != RelaySucceed {
|
||||
return fmt.Errorf("can't pool notary tx: hash %s, reason: %d", tx.Hash().StringLE(), byte(r))
|
||||
return fmt.Errorf("can't relay completed notary transaction: hash %s, reason: %s", tx.Hash().StringLE(), r.String())
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue