Skip to content

Commit

Permalink
add gas limit set
Browse files Browse the repository at this point in the history
  • Loading branch information
moremorefun committed May 18, 2021
1 parent 26b6acc commit 6cf90e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Usage of ./gomysql2struct:
-h help message
-key string
eth address private key
-limit uint
gas limit of tx
default is 0, when limit is 0, it will keep the old gas limit in the original tx
-swap string
rpc uri of eth
-txid string
Expand Down
8 changes: 6 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func main() {
var sourceKey = flag.String("key", "", "eth address private key")
var oldTxID = flag.String("txid", "", "txid to speed up")
var gas = flag.Int64("gas", 10, "gas price value in gwei")
var newGasLimit = flag.Uint64("limit", 0, "gas limit of tx\ndefault is 0, when limit is 0, it will keep the old gas limit in the original tx")
var h = flag.Bool("h", false, "help message")
flag.Parse()
if *h {
Expand Down Expand Up @@ -194,10 +195,13 @@ func main() {
log.Fatalf("input decode err: %s", err.Error())
}
}
gasLimit, err := hexutil.DecodeBig(rpcTx.Gas)
gasLimit, err := hexutil.DecodeUint64(rpcTx.Gas)
if err != nil {
log.Fatalf("error gas limit: %s", rpcTx.Gas)
}
if gasLimit < *newGasLimit {
gasLimit = *newGasLimit
}
nonce, err := hexutil.DecodeUint64(rpcTx.Nonce)
if err != nil {
log.Fatalf("error nonce: %s", rpcTx.Nonce)
Expand All @@ -216,7 +220,7 @@ func main() {
nonce,
common.HexToAddress(rpcTx.To),
value,
uint64(gasLimit.Int64()),
gasLimit,
gasPrice,
inputBs,
)
Expand Down

0 comments on commit 6cf90e6

Please sign in to comment.