File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -428,12 +428,24 @@ func (es *EventSystem) eventLoop() {
428
428
chainEvSub = es .backend .SubscribeChainEvent (chainEvCh )
429
429
)
430
430
431
- // Unsubscribe all events
432
- defer sub .Unsubscribe ()
433
- defer txSub .Unsubscribe ()
434
- defer rmLogsSub .Unsubscribe ()
435
- defer logsSub .Unsubscribe ()
436
- defer chainEvSub .Unsubscribe ()
431
+ defer func () {
432
+ // Unsubscribe all events
433
+ if sub != nil {
434
+ sub .Unsubscribe ()
435
+ }
436
+ if txSub != nil {
437
+ txSub .Unsubscribe ()
438
+ }
439
+ if rmLogsSub != nil {
440
+ rmLogsSub .Unsubscribe ()
441
+ }
442
+ if logsSub != nil {
443
+ logsSub .Unsubscribe ()
444
+ }
445
+ if chainEvSub != nil {
446
+ chainEvSub .Unsubscribe ()
447
+ }
448
+ }()
437
449
438
450
for i := UnknownSubscription ; i < LastIndexSubscription ; i ++ {
439
451
index [i ] = make (map [rpc.ID ]* subscription )
You can’t perform that action at this time.
0 commit comments