** * Check a receipt for the cumulative gas used. This will be our metric to check * if the tx threw. * * @param txhash Amount of gas used, an integer * @return 1 if the transaction went through, -1 if it threw. 0 otherwise */
(txhash string)
| 276 | * @return 1 if the transaction went through, -1 if it threw. 0 otherwise |
| 277 | */ |
| 278 | func CheckReceipt(txhash string) (int8, error) { |
| 279 | _gasUsed, err := client.Eth_gasUsed(txhash) |
| 280 | if err != nil { |
| 281 | return 0, fmt.Errorf("Error getting tx receipt: (%s)", err) |
| 282 | } else if _gasUsed == "" { |
| 283 | return 0, nil |
| 284 | } |
| 285 | _tx, _ := client.Eth_getTransactionByHash(txhash) |
| 286 | gasSent, _ := strconv.ParseUint(_tx.Gas, 0, 64) |
| 287 | gasUsed, _ := strconv.ParseUint(_gasUsed, 0, 64) |
| 288 | if gasUsed >= gasSent { |
| 289 | return -1, nil |
| 290 | } |
| 291 | return 1, nil |
| 292 | } |
| 293 | |
| 294 | |
| 295 | /** |
nothing calls this directly
no test coverage detected