mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 21:32:46 +00:00
Ensure only one transaction is used for RS input per room (#2178)
* Ensure the input API only uses a single transaction * Remove more of the dead query API call * Tidy up * Fix tests hopefully * Don't do unnecessary work for rooms that don't exist * Improve error, fix another case where transaction wasn't used properly * Add a unit test for checking single transaction on RS input API * Fix logic oops when deciding whether to use a transaction in storeEvent
This commit is contained in:
parent
a4e7d471af
commit
5106cc807c
13 changed files with 211 additions and 214 deletions
|
@ -125,39 +125,6 @@ func (r *Queryer) QueryStateAfterEvents(
|
|||
return nil
|
||||
}
|
||||
|
||||
// QueryMissingAuthPrevEvents implements api.RoomserverInternalAPI
|
||||
func (r *Queryer) QueryMissingAuthPrevEvents(
|
||||
ctx context.Context,
|
||||
request *api.QueryMissingAuthPrevEventsRequest,
|
||||
response *api.QueryMissingAuthPrevEventsResponse,
|
||||
) error {
|
||||
info, err := r.DB.RoomInfo(ctx, request.RoomID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info == nil {
|
||||
return errors.New("room doesn't exist")
|
||||
}
|
||||
|
||||
response.RoomExists = !info.IsStub
|
||||
response.RoomVersion = info.RoomVersion
|
||||
|
||||
for _, authEventID := range request.AuthEventIDs {
|
||||
if nids, err := r.DB.EventNIDs(ctx, []string{authEventID}); err != nil || len(nids) == 0 {
|
||||
response.MissingAuthEventIDs = append(response.MissingAuthEventIDs, authEventID)
|
||||
}
|
||||
}
|
||||
|
||||
for _, prevEventID := range request.PrevEventIDs {
|
||||
state, err := r.DB.StateAtEventIDs(ctx, []string{prevEventID})
|
||||
if err != nil || len(state) == 0 || (!state[0].IsCreate() && state[0].BeforeStateSnapshotNID == 0) {
|
||||
response.MissingPrevEventIDs = append(response.MissingPrevEventIDs, prevEventID)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryEventsByID implements api.RoomserverInternalAPI
|
||||
func (r *Queryer) QueryEventsByID(
|
||||
ctx context.Context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue