More tweaking

This commit is contained in:
Neil Alexander 2022-02-08 16:32:35 +00:00
parent 1e60d8720e
commit 0faec880d7
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -436,6 +436,7 @@ func (r *Inputer) fetchAuthEvents(
// Reuse these to reduce allocations. // Reuse these to reduce allocations.
authEventNIDs := make([]types.EventNID, 0, 5) authEventNIDs := make([]types.EventNID, 0, 5)
isRejected := false isRejected := false
nextAuthEvent:
for _, authEvent := range gomatrixserverlib.ReverseTopologicalOrdering( for _, authEvent := range gomatrixserverlib.ReverseTopologicalOrdering(
res.AuthEvents, res.AuthEvents,
gomatrixserverlib.TopologicalOrderByAuthEvents, gomatrixserverlib.TopologicalOrderByAuthEvents,
@ -444,14 +445,14 @@ func (r *Inputer) fetchAuthEvents(
// need to store it again or do anything further with it, so just skip // need to store it again or do anything further with it, so just skip
// over it rather than wasting cycles. // over it rather than wasting cycles.
if ev, ok := known[authEvent.EventID()]; ok && ev != nil { if ev, ok := known[authEvent.EventID()]; ok && ev != nil {
continue continue nextAuthEvent
} }
// Check the signatures of the event. If this fails then we'll simply // Check the signatures of the event. If this fails then we'll simply
// skip it, because gomatrixserverlib.Allowed() will notice a problem // skip it, because gomatrixserverlib.Allowed() will notice a problem
// if a critical event is missing anyway. // if a critical event is missing anyway.
if err := authEvent.VerifyEventSignatures(ctx, r.FSAPI.KeyRing()); err != nil { if err := authEvent.VerifyEventSignatures(ctx, r.FSAPI.KeyRing()); err != nil {
continue continue nextAuthEvent
} }
// In order to store the new auth event, we need to know its auth chain // In order to store the new auth event, we need to know its auth chain
@ -459,9 +460,10 @@ func (r *Inputer) fetchAuthEvents(
authEventNIDs = authEventNIDs[:0] authEventNIDs = authEventNIDs[:0]
for _, eventID := range authEvent.AuthEventIDs() { for _, eventID := range authEvent.AuthEventIDs() {
knownEvent, ok := known[eventID] knownEvent, ok := known[eventID]
if ok { if !ok {
authEventNIDs = append(authEventNIDs, knownEvent.EventNID) continue nextAuthEvent
} }
authEventNIDs = append(authEventNIDs, knownEvent.EventNID)
} }
// Check if the auth event should be rejected. // Check if the auth event should be rejected.