From bc10b803b97596f681757bfe3dc22e1846c6876c Mon Sep 17 00:00:00 2001 From: Sammy Libre Date: Mon, 16 Oct 2017 01:24:20 +0500 Subject: [PATCH] Add tx status check for Byzantium --- payouts/payer.go | 8 +++++++- rpc/rpc.go | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/payouts/payer.go b/payouts/payer.go index d8724340d..97009ebf1 100644 --- a/payouts/payer.go +++ b/payouts/payer.go @@ -201,12 +201,18 @@ func (u *PayoutsProcessor) process() { receipt, err := u.rpc.GetTxReceipt(txHash) if err != nil { log.Printf("Failed to get tx receipt for %v: %v", txHash, err) + continue } + // Tx has been mined if receipt != nil && receipt.Confirmed() { + if receipt.Successful() { + log.Printf("Payout tx successful for %s: %s", login, txHash) + } else { + log.Printf("Payout tx failed for %s: %s. Address contract throws on incoming tx.", login, txHash) + } break } } - log.Printf("Payout tx for %s confirmed: %s", login, txHash) } if mustPay > 0 { diff --git a/rpc/rpc.go b/rpc/rpc.go index 1380d6b67..96137bb77 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -46,16 +46,27 @@ type GetBlockReplyPart struct { Difficulty string `json:"difficulty"` } +const receiptStatusSuccessful = "0x1" + type TxReceipt struct { TxHash string `json:"transactionHash"` GasUsed string `json:"gasUsed"` BlockHash string `json:"blockHash"` + Status string `json:"status"` } func (r *TxReceipt) Confirmed() bool { return len(r.BlockHash) > 0 } +// Use with previous method +func (r *TxReceipt) Successful() bool { + if len(r.Status) > 0 { + return r.Status == receiptStatusSuccessful + } + return true +} + type Tx struct { Gas string `json:"gas"` GasPrice string `json:"gasPrice"`