Add option to disable sync of mempool transactions
This commit is contained in:
parent
d771291eca
commit
4c5c0bd32f
@ -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,21 +264,23 @@ func (b *EthereumRPC) subscribeEvents() error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// new mempool transaction subscription
|
if !b.ChainConfig.DisableMempoolSync {
|
||||||
if err := b.subscribe(func() (bchain.EVMClientSubscription, error) {
|
// new mempool transaction subscription
|
||||||
// invalidate the previous subscription - it is either the first one or there was an error
|
if err := b.subscribe(func() (bchain.EVMClientSubscription, error) {
|
||||||
b.newTxSubscription = nil
|
// invalidate the previous subscription - it is either the first one or there was an error
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), b.Timeout)
|
b.newTxSubscription = nil
|
||||||
defer cancel()
|
ctx, cancel := context.WithTimeout(context.Background(), b.Timeout)
|
||||||
sub, err := b.RPC.EthSubscribe(ctx, b.NewTx.Channel(), "newPendingTransactions")
|
defer cancel()
|
||||||
if err != nil {
|
sub, err := b.RPC.EthSubscribe(ctx, b.NewTx.Channel(), "newPendingTransactions")
|
||||||
return nil, errors.Annotatef(err, "EthSubscribe newPendingTransactions")
|
if err != nil {
|
||||||
|
return nil, errors.Annotatef(err, "EthSubscribe newPendingTransactions")
|
||||||
|
}
|
||||||
|
b.newTxSubscription = sub
|
||||||
|
glog.Info("Subscribed to newPendingTransactions")
|
||||||
|
return sub, nil
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
b.newTxSubscription = sub
|
|
||||||
glog.Info("Subscribed to newPendingTransactions")
|
|
||||||
return sub, nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user