mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
eth/filter, event: minor fixes
This commit is contained in:
parent
f11ac1eccc
commit
dec5843fed
2 changed files with 5 additions and 4 deletions
|
|
@ -136,7 +136,7 @@ func NewEventSystem(mux *event.TypeMux, backend Backend, lightMode bool) *EventS
|
||||||
// TODO(rjl493456442): use feed to subscribe pending log event
|
// TODO(rjl493456442): use feed to subscribe pending log event
|
||||||
m.pendingLogSub = m.mux.Subscribe(core.PendingLogsEvent{})
|
m.pendingLogSub = m.mux.Subscribe(core.PendingLogsEvent{})
|
||||||
|
|
||||||
// Make sure all the subscriptions are not empty
|
// Make sure none of the subscriptions are empty
|
||||||
if m.txSub == nil || m.logsSub == nil || m.rmLogsSub == nil || m.chainSub == nil ||
|
if m.txSub == nil || m.logsSub == nil || m.rmLogsSub == nil || m.chainSub == nil ||
|
||||||
m.pendingLogSub.Closed() {
|
m.pendingLogSub.Closed() {
|
||||||
log.Crit("Subscribe for event system failed")
|
log.Crit("Subscribe for event system failed")
|
||||||
|
|
@ -442,10 +442,8 @@ func (es *EventSystem) lightFilterLogs(header *types.Header, addresses []common.
|
||||||
|
|
||||||
// eventLoop (un)installs filters and processes mux events.
|
// eventLoop (un)installs filters and processes mux events.
|
||||||
func (es *EventSystem) eventLoop() {
|
func (es *EventSystem) eventLoop() {
|
||||||
var index = make(filterIndex)
|
// Ensure all subscriptions get cleaned up
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
// Unsubscribe all events
|
|
||||||
es.pendingLogSub.Unsubscribe()
|
es.pendingLogSub.Unsubscribe()
|
||||||
es.txSub.Unsubscribe()
|
es.txSub.Unsubscribe()
|
||||||
es.logsSub.Unsubscribe()
|
es.logsSub.Unsubscribe()
|
||||||
|
|
@ -453,6 +451,7 @@ func (es *EventSystem) eventLoop() {
|
||||||
es.chainSub.Unsubscribe()
|
es.chainSub.Unsubscribe()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
index := make(filterIndex)
|
||||||
for i := UnknownSubscription; i < LastIndexSubscription; i++ {
|
for i := UnknownSubscription; i < LastIndexSubscription; i++ {
|
||||||
index[i] = make(map[rpc.ID]*subscription)
|
index[i] = make(map[rpc.ID]*subscription)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,8 @@ func (s *TypeMuxSubscription) Unsubscribe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TypeMuxSubscription) Closed() bool {
|
func (s *TypeMuxSubscription) Closed() bool {
|
||||||
|
s.closeMu.Lock()
|
||||||
|
defer s.closeMu.Unlock()
|
||||||
return s.closed
|
return s.closed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue