mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-24 07:13:09 -06:00
Not finished refactor
This commit is contained in:
parent
9ebea8ecce
commit
ea1245870b
|
|
@ -468,18 +468,27 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser
|
||||||
// - fill in the gap completely then process event `e` returning no backwards extremity
|
// - fill in the gap completely then process event `e` returning no backwards extremity
|
||||||
// - fail to fill in the gap and tell us to terminate the transaction err=not nil
|
// - fail to fill in the gap and tell us to terminate the transaction err=not nil
|
||||||
// - fail to fill in the gap and tell us to fetch state at the new backwards extremity, and to not terminate the transaction
|
// - fail to fill in the gap and tell us to fetch state at the new backwards extremity, and to not terminate the transaction
|
||||||
newEvents, backwardsExtremity, err := t.getMissingEvents(gmectx, e, roomVersion, isInboundTxn)
|
newEvents, backwardsExtremity, err := t.getMissingEvents(gmectx, e, roomVersion, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if backwardsExtremity == nil {
|
if backwardsExtremity == nil {
|
||||||
// we filled in the gap!
|
// we filled in the gap!
|
||||||
return nil
|
fmt.Println("No backwards extremity")
|
||||||
|
//return nil
|
||||||
}
|
}
|
||||||
if len(newEvents) == 0 {
|
if len(newEvents) == 0 {
|
||||||
|
fmt.Println("No new events")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backwardsExtremity = &newEvents[0]
|
||||||
|
newEvents = newEvents[1:]
|
||||||
|
|
||||||
|
fmt.Println(len(newEvents), "new events")
|
||||||
|
|
||||||
|
fmt.Println("GO!")
|
||||||
|
|
||||||
// at this point we know we're going to have a gap: we need to work out the room state at the new backwards extremity.
|
// at this point we know we're going to have a gap: we need to work out the room state at the new backwards extremity.
|
||||||
// Therefore, we cannot just query /state_ids with this event to get the state before. Instead, we need to query
|
// Therefore, we cannot just query /state_ids with this event to get the state before. Instead, we need to query
|
||||||
// the state AFTER all the prev_events for this event, then apply state resolution to that to get the state before the event.
|
// the state AFTER all the prev_events for this event, then apply state resolution to that to get the state before the event.
|
||||||
|
|
@ -500,6 +509,8 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser
|
||||||
states = append(states, prevState)
|
states = append(states, prevState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("CHECKPOINT 1")
|
||||||
|
|
||||||
// Now that we have collected all of the state from the prev_events, we'll
|
// Now that we have collected all of the state from the prev_events, we'll
|
||||||
// run the state through the appropriate state resolution algorithm for the
|
// run the state through the appropriate state resolution algorithm for the
|
||||||
// room. This does a couple of things:
|
// room. This does a couple of things:
|
||||||
|
|
@ -512,6 +523,8 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("CHECKPOINT 2")
|
||||||
|
|
||||||
// First of all, send the backward extremity into the roomserver with the
|
// First of all, send the backward extremity into the roomserver with the
|
||||||
// newly resolved state. This marks the "oldest" point in the backfill and
|
// newly resolved state. This marks the "oldest" point in the backfill and
|
||||||
// sets the baseline state for any new events after this.
|
// sets the baseline state for any new events after this.
|
||||||
|
|
@ -523,6 +536,7 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser
|
||||||
t.haveEventIDs(),
|
t.haveEventIDs(),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Failed to SendEventWithState")
|
||||||
return fmt.Errorf("api.SendEventWithState: %w", err)
|
return fmt.Errorf("api.SendEventWithState: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -534,6 +548,7 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser
|
||||||
for i, newEvent := range newEvents {
|
for i, newEvent := range newEvents {
|
||||||
headeredNewEvents[i] = newEvent.Headered(roomVersion)
|
headeredNewEvents[i] = newEvent.Headered(roomVersion)
|
||||||
}
|
}
|
||||||
|
fmt.Println("Headered events:", len(headeredNewEvents))
|
||||||
if err = api.SendEvents(
|
if err = api.SendEvents(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
t.rsAPI,
|
t.rsAPI,
|
||||||
|
|
@ -541,8 +556,10 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser
|
||||||
api.DoNotSendToOtherServers,
|
api.DoNotSendToOtherServers,
|
||||||
nil,
|
nil,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
fmt.Println("ERROR!", err)
|
||||||
return fmt.Errorf("api.SendEvents: %w", err)
|
return fmt.Errorf("api.SendEvents: %w", err)
|
||||||
}
|
}
|
||||||
|
fmt.Println("SUCCESS!")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue