-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathevm_txm.go
70 lines (63 loc) · 1.81 KB
/
evm_txm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package evm
import (
"fmt"
"github.com/smartcontractkit/sqlx"
evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)
func newEvmTxm(
db *sqlx.DB,
cfg evmconfig.EVM,
evmRPCEnabled bool,
databaseConfig txmgr.DatabaseConfig,
listenerConfig txmgr.ListenerConfig,
client evmclient.Client,
lggr logger.Logger,
logPoller logpoller.LogPoller,
opts ChainRelayExtenderConfig,
) (txm txmgr.TxManager,
estimator gas.EvmFeeEstimator,
err error,
) {
chainID := cfg.ChainID()
if !evmRPCEnabled {
txm = &txmgr.NullTxManager{ErrMsg: fmt.Sprintf("Ethereum is disabled for chain %d", chainID)}
return txm, nil, nil
}
lggr = lggr.Named("Txm")
lggr.Infow("Initializing EVM transaction manager",
"bumpTxDepth", cfg.GasEstimator().BumpTxDepth(),
"maxInFlightTransactions", cfg.Transactions().MaxInFlight(),
"maxQueuedTransactions", cfg.Transactions().MaxQueued(),
"nonceAutoSync", cfg.NonceAutoSync(),
"limitDefault", cfg.GasEstimator().LimitDefault(),
)
// build estimator from factory
if opts.GenGasEstimator == nil {
estimator = gas.NewEstimator(lggr, client, cfg, cfg.GasEstimator())
} else {
estimator = opts.GenGasEstimator(chainID)
}
if opts.GenTxManager == nil {
txm, err = txmgr.NewTxm(
db,
cfg,
txmgr.NewEvmTxmFeeConfig(cfg.GasEstimator()),
cfg.Transactions(),
databaseConfig,
listenerConfig,
client,
lggr,
logPoller,
opts.KeyStore,
opts.EventBroadcaster,
estimator)
} else {
txm = opts.GenTxManager(chainID)
}
return
}