@@ -46,11 +46,10 @@ type eventFilter struct {
46
46
keysWithCodec map [string ][]types.ActorEventBlock // map of key names to a list of alternate values that may match
47
47
maxResults int // maximum number of results to collect, 0 is unlimited
48
48
49
- mu sync.Mutex
50
- collected []* CollectedEvent
51
- lastTaken time.Time
52
- ch chan <- interface {}
53
- excludeReverted bool
49
+ mu sync.Mutex
50
+ collected []* CollectedEvent
51
+ lastTaken time.Time
52
+ ch chan <- interface {}
54
53
}
55
54
56
55
var _ Filter = (* eventFilter )(nil )
@@ -84,9 +83,6 @@ func (f *eventFilter) ClearSubChannel() {
84
83
}
85
84
86
85
func (f * eventFilter ) CollectEvents (ctx context.Context , te * TipSetEvents , revert bool , resolver AddressResolver ) error {
87
- if f .excludeReverted && revert {
88
- return nil
89
- }
90
86
if ! f .matchTipset (te ) {
91
87
return nil
92
88
}
@@ -380,8 +376,14 @@ func (m *EventFilterManager) Revert(ctx context.Context, from, to *types.TipSet)
380
376
return nil
381
377
}
382
378
383
- func (m * EventFilterManager ) Install (ctx context.Context , minHeight , maxHeight abi.ChainEpoch , tipsetCid cid.Cid , addresses []address.Address ,
384
- keysWithCodec map [string ][]types.ActorEventBlock , excludeReverted bool ) (EventFilter , error ) {
379
+ func (m * EventFilterManager ) Fill (
380
+ ctx context.Context ,
381
+ minHeight ,
382
+ maxHeight abi.ChainEpoch ,
383
+ tipsetCid cid.Cid ,
384
+ addresses []address.Address ,
385
+ keysWithCodec map [string ][]types.ActorEventBlock ,
386
+ ) (EventFilter , error ) {
385
387
m .mu .Lock ()
386
388
if m .currentHeight == 0 {
387
389
// sync in progress, we haven't had an Apply
@@ -400,28 +402,44 @@ func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight a
400
402
}
401
403
402
404
f := & eventFilter {
403
- id : id ,
404
- minHeight : minHeight ,
405
- maxHeight : maxHeight ,
406
- tipsetCid : tipsetCid ,
407
- addresses : addresses ,
408
- keysWithCodec : keysWithCodec ,
409
- maxResults : m .MaxFilterResults ,
410
- excludeReverted : excludeReverted ,
405
+ id : id ,
406
+ minHeight : minHeight ,
407
+ maxHeight : maxHeight ,
408
+ tipsetCid : tipsetCid ,
409
+ addresses : addresses ,
410
+ keysWithCodec : keysWithCodec ,
411
+ maxResults : m .MaxFilterResults ,
411
412
}
412
413
413
414
if m .EventIndex != nil && minHeight != - 1 && minHeight < currentHeight {
414
415
// Filter needs historic events
416
+ excludeReverted := tipsetCid != cid .Undef
415
417
if err := m .EventIndex .prefillFilter (ctx , f , excludeReverted ); err != nil {
416
418
return nil , err
417
419
}
418
420
}
419
421
422
+ return f , nil
423
+ }
424
+
425
+ func (m * EventFilterManager ) Install (
426
+ ctx context.Context ,
427
+ minHeight ,
428
+ maxHeight abi.ChainEpoch ,
429
+ tipsetCid cid.Cid ,
430
+ addresses []address.Address ,
431
+ keysWithCodec map [string ][]types.ActorEventBlock ,
432
+ ) (EventFilter , error ) {
433
+ f , err := m .Fill (ctx , minHeight , maxHeight , tipsetCid , addresses , keysWithCodec )
434
+ if err != nil {
435
+ return nil , err
436
+ }
437
+
420
438
m .mu .Lock ()
421
439
if m .filters == nil {
422
440
m .filters = make (map [types.FilterID ]EventFilter )
423
441
}
424
- m .filters [id ] = f
442
+ m .filters [f .( * eventFilter ). id ] = f
425
443
m .mu .Unlock ()
426
444
427
445
return f , nil
0 commit comments