mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core: Add rejected feed
Any rejected transactions are sent through the rejected feed
This commit is contained in:
parent
4ce83632e9
commit
644d8c8f35
2 changed files with 10 additions and 6 deletions
|
|
@ -30,10 +30,10 @@ type DropTxsEvent struct{
|
|||
Reason string
|
||||
}
|
||||
|
||||
// RejectedTxsEvent is posted when a batch of transactions are removed from the transaction pool
|
||||
type RejectedTxsEvent struct{
|
||||
Txs []*types.Transaction
|
||||
Reason string
|
||||
// RejectedTxEvent is posted when a transaction is rejected from entering the transaction pool
|
||||
type RejectedTxEvent struct{
|
||||
Tx *types.Transaction
|
||||
Reason error
|
||||
}
|
||||
|
||||
// NewMinedBlockEvent is posted when a block has been imported.
|
||||
|
|
|
|||
|
|
@ -428,9 +428,9 @@ func (pool *TxPool) SubscribeDropTxsEvent(ch chan<- DropTxsEvent) event.Subscrip
|
|||
return pool.scope.Track(pool.dropTxFeed.Subscribe(ch))
|
||||
}
|
||||
|
||||
// SubscribeRejectedTxsEvent registers a subscription of RejectedTxsEvent and
|
||||
// SubscribeRejectedTxsEvent registers a subscription of RejectedTxEvent and
|
||||
// starts sending event to the given channel.
|
||||
func (pool *TxPool) SubscribeRejectedTxsEvent(ch chan<- RejectedTxsEvent) event.Subscription {
|
||||
func (pool *TxPool) SubscribeRejectedTxsEvent(ch chan<- RejectedTxEvent) event.Subscription {
|
||||
return pool.scope.Track(pool.rejectTxFeed.Subscribe(ch))
|
||||
}
|
||||
|
||||
|
|
@ -853,6 +853,10 @@ func (pool *TxPool) addTxs(txs []*types.Transaction, local, sync bool) []error {
|
|||
for errs[nilSlot] != nil {
|
||||
nilSlot++
|
||||
}
|
||||
pool.rejectTxFeed.Send(RejectedTxEvent{
|
||||
Tx: txs[nilSlot],
|
||||
Reason: err,
|
||||
})
|
||||
errs[nilSlot] = err
|
||||
}
|
||||
// Reorg the pool internals if needed and return
|
||||
|
|
|
|||
Loading…
Reference in a new issue