java-topology/defects/lotus-0001/patch/lotus-0001.patch

50 lines
1.7 KiB
Diff

# UNDF: UNDF-2026-000001018
--- a/chain/events/filter/event.go
+++ b/chain/events/filter/event.go
@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"math"
- "slices"
"sync"
"time"
@@ -45,8 +45,8 @@ type eventFilter struct {
id types.FilterID
minHeight abi.ChainEpoch // minimum epoch to apply filter or -1 if no minimum
maxHeight abi.ChainEpoch // maximum epoch to apply filter or -1 if no maximum
tipsetCid cid.Cid
- addresses []address.Address // list of actor addresses that are extpected to emit the event
+ addressSet map[address.Address]struct{} // set of actor addresses to match; empty means match all
keysWithCodec map[string][]types.ActorEventBlock // map of key names to a list of alternate values that may match
maxResults int // maximum number of results to collect, 0 is unlimited
@@ -180,10 +180,8 @@ func (f *eventFilter) LastTaken() time.Time {
// matchAddress reports whether an emitter address matches the filter.
func (f *eventFilter) matchAddress(o address.Address) bool {
- if len(f.addresses) == 0 {
+ if len(f.addressSet) == 0 {
return true
}
- // Assume short lists of addresses
- // TODO: binary search for longer lists or restrict list length
- return slices.Contains(f.addresses, o)
+ _, ok := f.addressSet[o]
+ return ok
}
@@ -382,7 +380,10 @@ func (m *EventFilterManager) Fill(
f := &eventFilter{
id: id,
minHeight: minHeight,
maxHeight: maxHeight,
tipsetCid: tipsetCid,
- addresses: addresses,
+ addressSet: make(map[address.Address]struct{}, len(addresses)),
keysWithCodec: keysWithCodec,
maxResults: m.MaxFilterResults,
}
+ for _, a := range addresses {
+ f.addressSet[a] = struct{}{}
+ }