Skip to content

Commit

Permalink
handle accepted/pending tx subs separately (#1288)
Browse files Browse the repository at this point in the history
* handle accepted/pending tx subs separately

* nit: naming
  • Loading branch information
darioush authored Aug 16, 2024
1 parent 9f36083 commit b42b7e7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,15 @@ func (es *EventSystem) handlePendingLogs(filters filterIndex, ev []*types.Log) {
}
}

func (es *EventSystem) handleTxsEvent(filters filterIndex, ev core.NewTxsEvent, accepted bool) {
func (es *EventSystem) handleTxsEvent(filters filterIndex, ev core.NewTxsEvent) {
for _, f := range filters[PendingTransactionsSubscription] {
f.txs <- ev.Txs
}
if accepted {
for _, f := range filters[AcceptedTransactionsSubscription] {
f.txs <- ev.Txs
}
}

func (es *EventSystem) handleTxsAcceptedEvent(filters filterIndex, ev core.NewTxsEvent) {
for _, f := range filters[AcceptedTransactionsSubscription] {
f.txs <- ev.Txs
}
}

Expand Down Expand Up @@ -565,7 +566,7 @@ func (es *EventSystem) eventLoop() {
for {
select {
case ev := <-es.txsCh:
es.handleTxsEvent(index, ev, false)
es.handleTxsEvent(index, ev)
case ev := <-es.logsCh:
es.handleLogs(index, ev)
case ev := <-es.logsAcceptedCh:
Expand All @@ -579,7 +580,7 @@ func (es *EventSystem) eventLoop() {
case ev := <-es.chainAcceptedCh:
es.handleChainAcceptedEvent(index, ev)
case ev := <-es.txsAcceptedCh:
es.handleTxsEvent(index, ev, true)
es.handleTxsAcceptedEvent(index, ev)

case f := <-es.install:
if f.typ == MinedAndPendingLogsSubscription {
Expand Down

0 comments on commit b42b7e7

Please sign in to comment.