From 71eebd6bc347601feca4f72c0b5a72edbf489c55 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 29 Jun 2021 13:39:51 +0100 Subject: [PATCH] Deduplicate more --- federationapi/routing/send.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index 9aa0239e..9c750923 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -791,7 +791,7 @@ func (t *txnReq) lookupStateAfterEvent(ctx context.Context, roomVersion gomatrix default: return nil, false, fmt.Errorf("t.lookupEvent: %w", err) } - t.cacheAndReturn(h) + h = t.cacheAndReturn(h) if h.StateKey() != nil { addedToState := false for i := range respState.StateEvents { @@ -1070,8 +1070,8 @@ func (t *txnReq) lookupMissingStateViaStateIDs(ctx context.Context, roomID, even return nil, err } for i := range queryRes.Events { + queryRes.Events[i] = t.cacheAndReturn(queryRes.Events[i]) evID := queryRes.Events[i].EventID() - t.cacheAndReturn(queryRes.Events[i]) if missing[evID] { delete(missing, evID) } @@ -1235,8 +1235,7 @@ func (t *txnReq) lookupEvent(ctx context.Context, roomVersion gomatrixserverlib. util.GetLogger(ctx).WithError(err).Warnf("Transaction: Couldn't validate signature of event %q", event.EventID()) return nil, verifySigError{event.EventID(), err} } - h := event.Headered(roomVersion) - t.cacheAndReturn(h) + h := t.cacheAndReturn(event.Headered(roomVersion)) t.newEventsMutex.Lock() t.newEvents[h.EventID()] = true t.newEventsMutex.Unlock()