diff --git a/pkg/network/relay_reason.go b/pkg/network/relay_reason.go index 3e7e095d1..0b58759ff 100644 --- a/pkg/network/relay_reason.go +++ b/pkg/network/relay_reason.go @@ -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 diff --git a/pkg/network/relay_reason_string.go b/pkg/network/relay_reason_string.go new file mode 100644 index 000000000..0c2da4d04 --- /dev/null +++ b/pkg/network/relay_reason_string.go @@ -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]] +} diff --git a/pkg/network/server.go b/pkg/network/server.go index 4b68d05c0..648d65477 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -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 })