core, eth: minor txpool event cleanups

This commit is contained in:
Péter Szilágyi
2018-05-18 11:45:52 +03:00
parent a2e43d28d0
commit 49719e21bc
19 changed files with 89 additions and 92 deletions

View File

@ -49,7 +49,7 @@ const (
// history request.
historyUpdateRange = 50
// txChanSize is the size of channel listening to TxsPreEvent.
// txChanSize is the size of channel listening to NewTxsEvent.
// The number is referenced from the size of tx pool.
txChanSize = 4096
// chainHeadChanSize is the size of channel listening to ChainHeadEvent.
@ -57,9 +57,9 @@ const (
)
type txPool interface {
// SubscribeTxPreEvent should return an event subscription of
// TxsPreEvent and send events to the given channel.
SubscribeTxPreEvent(chan<- core.TxsPreEvent) event.Subscription
// SubscribeNewTxsEvent should return an event subscription of
// NewTxsEvent and send events to the given channel.
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
}
type blockChain interface {
@ -150,8 +150,8 @@ func (s *Service) loop() {
headSub := blockchain.SubscribeChainHeadEvent(chainHeadCh)
defer headSub.Unsubscribe()
txEventCh := make(chan core.TxsPreEvent, txChanSize)
txSub := txpool.SubscribeTxPreEvent(txEventCh)
txEventCh := make(chan core.NewTxsEvent, txChanSize)
txSub := txpool.SubscribeNewTxsEvent(txEventCh)
defer txSub.Unsubscribe()
// Start a goroutine that exhausts the subsciptions to avoid events piling up