Skip to content

Commit

Permalink
Add tx status check for Byzantium
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy007 committed Oct 15, 2017
1 parent ba74320 commit bc10b80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion payouts/payer.go
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions rpc/rpc.go
Expand Up @@ -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"`
Expand Down

0 comments on commit bc10b80

Please sign in to comment.