mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core,eth,internal/ethapi,les: Extend API Backend to subscribe dropped txs
This extends the API Backend interface and respective implementations with the ability to subscribe to dropped and rejected transactions.
This commit is contained in:
parent
644d8c8f35
commit
29e619a95b
4 changed files with 56 additions and 2 deletions
|
|
@ -428,9 +428,9 @@ func (pool *TxPool) SubscribeDropTxsEvent(ch chan<- DropTxsEvent) event.Subscrip
|
||||||
return pool.scope.Track(pool.dropTxFeed.Subscribe(ch))
|
return pool.scope.Track(pool.dropTxFeed.Subscribe(ch))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeRejectedTxsEvent registers a subscription of RejectedTxEvent and
|
// SubscribeRejectedTxEvent registers a subscription of RejectedTxEvent and
|
||||||
// starts sending event to the given channel.
|
// starts sending event to the given channel.
|
||||||
func (pool *TxPool) SubscribeRejectedTxsEvent(ch chan<- RejectedTxEvent) event.Subscription {
|
func (pool *TxPool) SubscribeRejectedTxEvent(ch chan<- RejectedTxEvent) event.Subscription {
|
||||||
return pool.scope.Track(pool.rejectTxFeed.Subscribe(ch))
|
return pool.scope.Track(pool.rejectTxFeed.Subscribe(ch))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
21
eth/dropped_tx_subscription.go
Normal file
21
eth/dropped_tx_subscription.go
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
// This file extends the EthAPIBackend with functions for BlockNative's dropped
|
||||||
|
// transaction feeds.
|
||||||
|
//
|
||||||
|
// As this is part of a fork, and not included in core geth, keeping it in a
|
||||||
|
// separate file helps protect against potential merge conflicts. If this were
|
||||||
|
// ever to be merged into core geth, it should be relocated to ./api_backend.go
|
||||||
|
|
||||||
|
package eth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (b *EthAPIBackend) SubscribeDropTxsEvent(ch chan<- core.DropTxsEvent) event.Subscription {
|
||||||
|
return b.eth.TxPool().SubscribeDropTxsEvent(ch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *EthAPIBackend) SubscribeRejectedTxEvent(ch chan<- core.RejectedTxEvent) event.Subscription {
|
||||||
|
return b.eth.TxPool().SubscribeRejectedTxEvent(ch)
|
||||||
|
}
|
||||||
|
|
@ -73,6 +73,8 @@ type Backend interface {
|
||||||
Stats() (pending int, queued int)
|
Stats() (pending int, queued int)
|
||||||
TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
|
TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
|
||||||
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
|
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
|
||||||
|
SubscribeRejectedTxEvent(chan<- core.RejectedTxEvent) event.Subscription
|
||||||
|
SubscribeDropTxsEvent(chan<- core.DropTxsEvent) event.Subscription
|
||||||
|
|
||||||
// Filter API
|
// Filter API
|
||||||
BloomStatus() (uint64, uint64)
|
BloomStatus() (uint64, uint64)
|
||||||
|
|
|
||||||
31
les/dropped_tx_subscription.go
Normal file
31
les/dropped_tx_subscription.go
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
// This file extends the LesApiBackend with functions for BlockNative's dropped
|
||||||
|
// transaction feeds.
|
||||||
|
//
|
||||||
|
// As this is part of a fork, and not included in core geth, keeping it in a
|
||||||
|
// separate file helps protect against potential merge conflicts. If this were
|
||||||
|
// ever to be merged into core geth, it should be relocated to ./api_backend.go
|
||||||
|
|
||||||
|
package les
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
type unimplementedSubscription struct{}
|
||||||
|
|
||||||
|
func (s *unimplementedSubscription) Unsubscribe() {}
|
||||||
|
func (s *unimplementedSubscription) Err() <-chan error {
|
||||||
|
ch := make(chan error, 1)
|
||||||
|
ch <- errors.New("Subscription type not implemented")
|
||||||
|
return ch
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *LesApiBackend) SubscribeDropTxsEvent(ch chan<- core.DropTxsEvent) event.Subscription {
|
||||||
|
return &unimplementedSubscription{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *LesApiBackend) SubscribeRejectedTxEvent(ch chan<- core.RejectedTxEvent) event.Subscription {
|
||||||
|
return &unimplementedSubscription{}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue