Skip to content

Commit

Permalink
revert #17, #18, #19
Browse files Browse the repository at this point in the history
  • Loading branch information
calbera committed Apr 25, 2023
1 parent de6c523 commit bf6ba6c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
)
Expand Down Expand Up @@ -197,7 +198,7 @@ type EventSystem struct {
lastHead *types.Header

// Subscriptions
// txsSub event.Subscription // Subscription for new transaction event
txsSub event.Subscription // Subscription for new transaction event
logsSub event.Subscription // Subscription for new log event
rmLogsSub event.Subscription // Subscription for removed log event
pendingLogsSub event.Subscription // Subscription for pending log event
Expand Down Expand Up @@ -234,17 +235,16 @@ func NewEventSystem(sys *FilterSystem, lightMode bool) *EventSystem {
}

// Subscribe events
// m.txsSub = m.backend.SubscribeNewTxsEvent(m.txsCh)
m.txsSub = m.backend.SubscribeNewTxsEvent(m.txsCh)
m.logsSub = m.backend.SubscribeLogsEvent(m.logsCh)
m.rmLogsSub = m.backend.SubscribeRemovedLogsEvent(m.rmLogsCh)
m.chainSub = m.backend.SubscribeChainEvent(m.chainCh)
m.pendingLogsSub = m.backend.SubscribePendingLogsEvent(m.pendingLogsCh)

// TODO: enable this check once m.txsSub is implemented
// // Make sure none of the subscriptions are empty
// if m.txsSub == nil || m.logsSub == nil || m.rmLogsSub == nil || m.chainSub == nil || m.pendingLogsSub == nil {
// log.Crit("Subscribe for event system failed")
// }
// Make sure none of the subscriptions are empty
if m.txsSub == nil || m.logsSub == nil || m.rmLogsSub == nil || m.chainSub == nil || m.pendingLogsSub == nil {
log.Crit("Subscribe for event system failed")
}

go m.eventLoop()
return m
Expand Down Expand Up @@ -452,11 +452,11 @@ func (es *EventSystem) handleRemovedLogs(filters filterIndex, ev core.RemovedLog
}
}

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

func (es *EventSystem) handleChainEvent(filters filterIndex, ev core.ChainEvent) {
for _, f := range filters[BlocksSubscription] {
Expand Down Expand Up @@ -567,8 +567,8 @@ func (es *EventSystem) eventLoop() {

for {
select {
// case ev := <-es.txsCh:
// es.handleTxsEvent(index, ev)
case ev := <-es.txsCh:
es.handleTxsEvent(index, ev)
case ev := <-es.logsCh:
es.handleLogs(index, ev)
case ev := <-es.rmLogsCh:
Expand Down Expand Up @@ -599,8 +599,8 @@ func (es *EventSystem) eventLoop() {
close(f.err)

// System stopped
// case <-es.txsSub.Err():
// return
case <-es.txsSub.Err():
return
case <-es.logsSub.Err():
return
case <-es.rmLogsSub.Err():
Expand Down

0 comments on commit bf6ba6c

Please sign in to comment.