error.go 670 B

123456789101112131415161718192021222324
  1. // Copyright (c) 2014-2016 The btcsuite developers
  2. // Use of this source code is governed by an ISC
  3. // license that can be found in the LICENSE file.
  4. package mempool
  5. import (
  6. "fmt"
  7. "github.com/pkt-cash/pktd/btcutil/er"
  8. "github.com/pkt-cash/pktd/wire"
  9. "github.com/pkt-cash/pktd/wire/ruleerror"
  10. )
  11. // txRuleError creates an underlying TxRuleError with the given a set of
  12. // arguments and returns a RuleError that encapsulates it.
  13. func txRuleError(c wire.RejectCode, desc string) er.R {
  14. code := ruleerror.Err.NumberToCode(int(c))
  15. if code == nil {
  16. return ruleerror.ErrUnknown.New(fmt.Sprintf("code: %d reason: %s", c, desc), nil)
  17. }
  18. return code.New(desc, nil)
  19. }