diff --git a/core/tx_pool.go b/core/tx_pool.go index 87881f9fb0..322a3e07ec 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -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 RejectedTxEvent and +// SubscribeRejectedTxEvent registers a subscription of RejectedTxEvent and // 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)) } diff --git a/eth/dropped_tx_subscription.go b/eth/dropped_tx_subscription.go new file mode 100644 index 0000000000..cd8ca02c25 --- /dev/null +++ b/eth/dropped_tx_subscription.go @@ -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) +} diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 245091df35..4c0d81be6f 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -73,6 +73,8 @@ type Backend interface { Stats() (pending int, queued int) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription + SubscribeRejectedTxEvent(chan<- core.RejectedTxEvent) event.Subscription + SubscribeDropTxsEvent(chan<- core.DropTxsEvent) event.Subscription // Filter API BloomStatus() (uint64, uint64) diff --git a/les/dropped_tx_subscription.go b/les/dropped_tx_subscription.go new file mode 100644 index 0000000000..23bc2b91c4 --- /dev/null +++ b/les/dropped_tx_subscription.go @@ -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{} +}