Add option to disable sync of mempool transactions

This commit is contained in:
Martin Boehm 2024-09-24 18:19:05 +02:00
parent d771291eca
commit 4c5c0bd32f

View File

@ -50,6 +50,7 @@ type Configuration struct {
ProcessInternalTransactions bool `json:"processInternalTransactions"` ProcessInternalTransactions bool `json:"processInternalTransactions"`
ProcessZeroInternalTransactions bool `json:"processZeroInternalTransactions"` ProcessZeroInternalTransactions bool `json:"processZeroInternalTransactions"`
ConsensusNodeVersionURL string `json:"consensusNodeVersion"` ConsensusNodeVersionURL string `json:"consensusNodeVersion"`
DisableMempoolSync bool `json:"disableMempoolSync,omitempty"`
} }
// EthereumRPC is an interface to JSON-RPC eth service. // EthereumRPC is an interface to JSON-RPC eth service.
@ -174,7 +175,7 @@ func (b *EthereumRPC) Initialize() error {
func (b *EthereumRPC) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) { func (b *EthereumRPC) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) {
if b.Mempool == nil { if b.Mempool == nil {
b.Mempool = bchain.NewMempoolEthereumType(chain, b.ChainConfig.MempoolTxTimeoutHours, b.ChainConfig.QueryBackendOnMempoolResync) b.Mempool = bchain.NewMempoolEthereumType(chain, b.ChainConfig.MempoolTxTimeoutHours, b.ChainConfig.QueryBackendOnMempoolResync)
glog.Info("mempool created, MempoolTxTimeoutHours=", b.ChainConfig.MempoolTxTimeoutHours, ", QueryBackendOnMempoolResync=", b.ChainConfig.QueryBackendOnMempoolResync) glog.Info("mempool created, MempoolTxTimeoutHours=", b.ChainConfig.MempoolTxTimeoutHours, ", QueryBackendOnMempoolResync=", b.ChainConfig.QueryBackendOnMempoolResync, ", DisableMempoolSync=", b.ChainConfig.DisableMempoolSync)
} }
return b.Mempool, nil return b.Mempool, nil
} }
@ -263,6 +264,7 @@ func (b *EthereumRPC) subscribeEvents() error {
} }
}() }()
if !b.ChainConfig.DisableMempoolSync {
// new mempool transaction subscription // new mempool transaction subscription
if err := b.subscribe(func() (bchain.EVMClientSubscription, error) { if err := b.subscribe(func() (bchain.EVMClientSubscription, error) {
// invalidate the previous subscription - it is either the first one or there was an error // invalidate the previous subscription - it is either the first one or there was an error
@ -279,6 +281,7 @@ func (b *EthereumRPC) subscribeEvents() error {
}); err != nil { }); err != nil {
return err return err
} }
}
return nil return nil
} }