Permalink
Browse files

Add tx status check for Byzantium

  • Loading branch information...
sammy007 committed Oct 15, 2017
1 parent ba74320 commit bc10b803b97596f681757bfe3dc22e1846c6876c
Showing with 18 additions and 1 deletion.
  1. +7 −1 payouts/payer.go
  2. +11 −0 rpc/rpc.go
View
@@ -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 {
View
@@ -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"`

0 comments on commit bc10b80

Please sign in to comment.