Move rpc errors to rpc package.
This commit is contained in:
parent
c1b315bca1
commit
5d8215e6b7
@ -30,9 +30,6 @@ const (
|
||||
// requiredConfs is the number of confirmations required to consider a
|
||||
// ticket purchase or a fee transaction to be final.
|
||||
requiredConfs = 6
|
||||
// errNoTxInfo is defined in dcrd/dcrjson. Copying here so we dont need to
|
||||
// import the whole package.
|
||||
errNoTxInfo = -5
|
||||
)
|
||||
|
||||
// Notify is called every time a block notification is received from dcrd.
|
||||
@ -81,12 +78,12 @@ func blockConnected() {
|
||||
for _, ticket := range unconfirmed {
|
||||
tktTx, err := dcrdClient.GetRawTransaction(ticket.Hash)
|
||||
if err != nil {
|
||||
// errNoTxInfo here probably indicates a tx which was never mined
|
||||
// ErrNoTxInfo here probably indicates a tx which was never mined
|
||||
// and has been removed from the mempool. For example, a ticket
|
||||
// purchase tx close to an sdiff change, or a ticket purchase tx
|
||||
// which expired. Remove it from the db.
|
||||
var e *wsrpc.Error
|
||||
if errors.As(err, &e) && e.Code == errNoTxInfo {
|
||||
if errors.As(err, &e) && e.Code == rpc.ErrNoTxInfo {
|
||||
log.Infof("Removing unconfirmed ticket from db - no information available "+
|
||||
"about transaction %s", err.Error())
|
||||
|
||||
|
||||
12
rpc/dcrd.go
12
rpc/dcrd.go
@ -17,9 +17,13 @@ import (
|
||||
|
||||
const (
|
||||
requiredDcrdVersion = "6.1.1"
|
||||
// errRPCDuplicateTx is defined in dcrd/dcrjson. Copying here so we dont
|
||||
// need to import the whole package.
|
||||
errRPCDuplicateTx = -40
|
||||
)
|
||||
|
||||
// These error codes are defined in dcrd/dcrjson. They are copied here so we
|
||||
// dont need to import the whole package.
|
||||
const (
|
||||
ErrRPCDuplicateTx = -40
|
||||
ErrNoTxInfo = -5
|
||||
)
|
||||
|
||||
// DcrdRPC provides methods for calling dcrd JSON-RPCs without exposing the details
|
||||
@ -120,7 +124,7 @@ func (c *DcrdRPC) SendRawTransaction(txHex string) error {
|
||||
|
||||
// Exists in mempool.
|
||||
var e *wsrpc.Error
|
||||
if errors.As(err, &e) && e.Code == errRPCDuplicateTx {
|
||||
if errors.As(err, &e) && e.Code == ErrRPCDuplicateTx {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user