core: use error wrapping to provide more details

This commit is contained in:
Roman Khimov 2020-08-06 18:34:44 +03:00
parent 5ef08f60ae
commit 205f52c563
4 changed files with 18 additions and 18 deletions

View file

@ -843,12 +843,12 @@ func (s *Server) relayBlocksLoop() {
// verifyAndPoolTX verifies the TX and adds it to the local mempool.
func (s *Server) verifyAndPoolTX(t *transaction.Transaction) RelayReason {
if err := s.chain.PoolTx(t); err != nil {
switch err {
case core.ErrAlreadyExists:
switch {
case errors.Is(err, core.ErrAlreadyExists):
return RelayAlreadyExists
case core.ErrOOM:
case errors.Is(err, core.ErrOOM):
return RelayOutOfMemory
case core.ErrPolicy:
case errors.Is(err, core.ErrPolicy):
return RelayPolicyFail
default:
return RelayInvalid