diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index 636325f43..2142ead38 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -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 // - 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 - newEvents, backwardsExtremity, err := t.getMissingEvents(gmectx, e, roomVersion, isInboundTxn) + newEvents, backwardsExtremity, err := t.getMissingEvents(gmectx, e, roomVersion, true) if err != nil { return err } if backwardsExtremity == nil { // we filled in the gap! - return nil + fmt.Println("No backwards extremity") + //return nil } if len(newEvents) == 0 { + fmt.Println("No new events") 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. // 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. @@ -500,6 +509,8 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser states = append(states, prevState) } + fmt.Println("CHECKPOINT 1") + // 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 // room. This does a couple of things: @@ -512,6 +523,8 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser return err } + fmt.Println("CHECKPOINT 2") + // First of all, send the backward extremity into the roomserver with the // newly resolved state. This marks the "oldest" point in the backfill and // 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(), ) if err != nil { + fmt.Println("Failed to SendEventWithState") 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 { headeredNewEvents[i] = newEvent.Headered(roomVersion) } + fmt.Println("Headered events:", len(headeredNewEvents)) if err = api.SendEvents( context.Background(), t.rsAPI, @@ -541,8 +556,10 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser api.DoNotSendToOtherServers, nil, ); err != nil { + fmt.Println("ERROR!", err) return fmt.Errorf("api.SendEvents: %w", err) } + fmt.Println("SUCCESS!") return nil }