mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
More aggressive event caching
This commit is contained in:
parent
e2b6a90d90
commit
7c03546a9e
1 changed files with 14 additions and 0 deletions
|
@ -985,6 +985,12 @@ func (t *txnReq) getMissingEvents(ctx context.Context, e *gomatrixserverlib.Even
|
|||
// For now, we do not allow Case B, so reject the event.
|
||||
logger.Infof("get_missing_events returned %d events", len(missingResp.Events))
|
||||
|
||||
// Make sure events from the missingResp are using the cache - missing events
|
||||
// will be added and duplicates will be removed.
|
||||
for i, ev := range missingResp.Events {
|
||||
missingResp.Events[i] = t.cacheAndReturn(ev.Headered(roomVersion)).Unwrap()
|
||||
}
|
||||
|
||||
// topologically sort and sanity check that we are making forward progress
|
||||
newEvents = gomatrixserverlib.ReverseTopologicalOrdering(missingResp.Events, gomatrixserverlib.TopologicalOrderByPrevEvents)
|
||||
shouldHaveSomeEventIDs := e.PrevEventIDs()
|
||||
|
@ -1023,6 +1029,13 @@ func (t *txnReq) lookupMissingStateViaState(ctx context.Context, roomID, eventID
|
|||
if err := state.Check(ctx, t.keys, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Cache the results of this state lookup.
|
||||
for _, ev := range state.AuthEvents {
|
||||
t.cacheAndReturn(ev.Headered(roomVersion))
|
||||
}
|
||||
for _, ev := range state.StateEvents {
|
||||
t.cacheAndReturn(ev.Headered(roomVersion))
|
||||
}
|
||||
return &state, nil
|
||||
}
|
||||
|
||||
|
@ -1222,6 +1235,7 @@ func (t *txnReq) lookupEvent(ctx context.Context, roomVersion gomatrixserverlib.
|
|||
return nil, verifySigError{event.EventID(), err}
|
||||
}
|
||||
h := event.Headered(roomVersion)
|
||||
t.cacheAndReturn(h)
|
||||
t.newEventsMutex.Lock()
|
||||
t.newEvents[h.EventID()] = true
|
||||
t.newEventsMutex.Unlock()
|
||||
|
|
Loading…
Reference in a new issue