Skip to content

Commit 7e3b0bc

Browse files
committed
Extracted TX resubmission constants for commands to cmd.go
1 parent 207339f commit 7e3b0bc

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

pkg/cmd/cmd.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package cmd
44

55
import (
66
"fmt"
7+
"math/big"
8+
"time"
79

810
"github.com/ethereum/go-ethereum/common"
911
"github.com/keep-network/keep-common/pkg/cmd/flag"
@@ -41,6 +43,19 @@ var (
4143
// interaction. The value, if that flag is passed on the command line, is
4244
// stored in this variable.
4345
ValueFlagValue *flag.Uint256 = &flag.Uint256{}
46+
47+
// DefaultMiningCheckInterval is the default interval in which transaction
48+
// mining status is checked. If the transaction is not mined within this
49+
// time, the gas price is increased and transaction is resubmitted.
50+
// This value can be overwritten in the configuration file.
51+
DefaultMiningCheckInterval = 60 * time.Second
52+
53+
// DefaultMaxGasPrice specifies the default maximum gas price the client is
54+
// willing to pay for the transaction to be mined. The offered transaction
55+
// gas price can not be higher than the max gas price value. If the maximum
56+
// allowed gas price is reached, no further resubmission attempts are
57+
// performed. This value can be overwritten in the configuration file.
58+
DefaultMaxGasPrice = big.NewInt(50000000000) // 50 Gwei
4459
)
4560

4661
// AvailableCommands is the exported list of generated commands that can be

tools/generators/ethereum/command.go.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ func initialize{{.Class}}(c *cli.Context) (*contract.{{.Class}}, error) {
215215
)
216216
}
217217

218-
checkInterval := 30 * time.Second
219-
maxGasPrice := big.NewInt(50000000000) // 50 Gwei
218+
checkInterval := cmd.DefaultMiningCheckInterval
219+
maxGasPrice := cmd.DefaultMaxGasPrice
220220
if config.MiningCheckInterval != 0 {
221221
checkInterval = time.Duration(config.MiningCheckInterval) * time.Second
222222
}

tools/generators/ethereum/command_template_content.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ func initialize{{.Class}}(c *cli.Context) (*contract.{{.Class}}, error) {
218218
)
219219
}
220220
221-
checkInterval := 30 * time.Second
222-
maxGasPrice := big.NewInt(50000000000) // 50 Gwei
221+
checkInterval := cmd.DefaultMiningCheckInterval
222+
maxGasPrice := cmd.DefaultMaxGasPrice
223223
if config.MiningCheckInterval != 0 {
224224
checkInterval = time.Duration(config.MiningCheckInterval) * time.Second
225225
}

tools/generators/ethereum/contract.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func New{{.Class}}(
4545
accountKey *keystore.Key,
4646
backend bind.ContractBackend,
4747
nonceManager *ethutil.NonceManager,
48-
miningWaiter *ethutil.MiningWaiter,
48+
miningWaiter *ethutil.MiningWaiter,
4949
transactionMutex *sync.Mutex,
5050
) (*{{.Class}}, error) {
5151
callerOptions := &bind.CallOpts{

tools/generators/ethereum/contract_template_content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func New{{.Class}}(
4848
accountKey *keystore.Key,
4949
backend bind.ContractBackend,
5050
nonceManager *ethutil.NonceManager,
51-
miningWaiter *ethutil.MiningWaiter,
51+
miningWaiter *ethutil.MiningWaiter,
5252
transactionMutex *sync.Mutex,
5353
) (*{{.Class}}, error) {
5454
callerOptions := &bind.CallOpts{

0 commit comments

Comments
 (0)