From 0d17b173cf5f24655ab309a535ab376a08e81acb Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 15 Dec 2024 09:36:17 +0000 Subject: [PATCH] Review comments --- authstate.go | 10 ++-------- stateresolutionv2.go | 8 +++++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/authstate.go b/authstate.go index 2344442d..7cfe67af 100644 --- a/authstate.go +++ b/authstate.go @@ -165,10 +165,7 @@ func checkAllowedByAuthEvents( event PDU, eventsByID map[string]PDU, missingAuth EventProvider, userIDForSender spec.UserIDForSender, ) error { - authEvents, err := NewAuthEvents(nil) - if err != nil { - return err - } + authEvents, _ := NewAuthEvents(nil) for _, ae := range event.AuthEventIDs() { retryEvent: @@ -338,10 +335,7 @@ func CheckSendJoinResponse( } eventsByID := map[string]PDU{} - authEventProvider, err := NewAuthEvents(nil) - if err != nil { - return nil, err - } + authEventProvider, _ := NewAuthEvents(nil) // Since checkAllowedByAuthEvents needs to be able to look up any of the // auth events by ID only, we will build a map which contains references diff --git a/stateresolutionv2.go b/stateresolutionv2.go index 36af1b41..686307e4 100644 --- a/stateresolutionv2.go +++ b/stateresolutionv2.go @@ -444,10 +444,12 @@ func (r *stateResolverV2) getFirstPowerLevelMainlineEvent(event PDU) ( func (r *stateResolverV2) authAndApplyEvents(events ...PDU) { addFromAuthEventsIfNotRejected := func(event PDU, eventType, stateKey string) { for _, authEventID := range event.AuthEventIDs() { - if _, ok := r.isRejectedCache[authEventID]; !ok { - r.isRejectedCache[authEventID] = r.isRejectedFn(authEventID) + rejected, ok := r.isRejectedCache[authEventID] + if !ok { + rejected = r.isRejectedFn(authEventID) + r.isRejectedCache[authEventID] = rejected } - if rejected := r.isRejectedCache[authEventID]; rejected { + if rejected { continue } authEv, ok := r.authEventMap[authEventID]