mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-31 10:43:10 -06:00
Try to avoid falling down the hole of using a trustworthy but empty state snapshot for non-create events
This commit is contained in:
parent
6abd2df1f1
commit
ffcc04b980
|
|
@ -138,9 +138,13 @@ func (t *missingStateReq) processEventWithMissingState(
|
||||||
case 1:
|
case 1:
|
||||||
// There's only one previous state - if it's trustworthy (came from a
|
// There's only one previous state - if it's trustworthy (came from a
|
||||||
// local state snapshot which will already have been through state res),
|
// local state snapshot which will already have been through state res),
|
||||||
// use it as-is. There's no point in resolving it again.
|
// use it as-is. There's no point in resolving it again. Only trust a
|
||||||
if states[0].trustworthy {
|
// trustworthy state snapshot if it actually contains some state for all
|
||||||
|
// non-create events, otherwise we need to resolve what came from federation.
|
||||||
|
isCreate := backwardsExtremity.Type() == gomatrixserverlib.MRoomCreate && backwardsExtremity.StateKeyEquals("")
|
||||||
|
if states[0].trustworthy && (isCreate || len(states[0].StateEvents) > 0) {
|
||||||
resolvedState = states[0].RespState
|
resolvedState = states[0].RespState
|
||||||
|
logger.Infof("Found single trustworthy state snapshot for backward extremity %s", backwardsExtremity.EventID())
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Otherwise, if it isn't trustworthy (came from federation), run it through
|
// Otherwise, if it isn't trustworthy (came from federation), run it through
|
||||||
|
|
@ -492,9 +496,11 @@ Event:
|
||||||
return newEvents, true, nil
|
return newEvents, true, nil
|
||||||
}
|
}
|
||||||
// we don't have the state at this earliest event from /g_m_e so we won't have state for later events either
|
// we don't have the state at this earliest event from /g_m_e so we won't have state for later events either
|
||||||
|
logger.Warnf("State unknown for backward extremity %s", earliestNewEvent.EventID())
|
||||||
return newEvents, false, nil
|
return newEvents, false, nil
|
||||||
}
|
}
|
||||||
// StateAtEventIDs returned some kind of state for the earliest event so we can fill in the gap!
|
// StateAtEventIDs returned some kind of state for the earliest event so we can fill in the gap!
|
||||||
|
logger.Infof("State known for backward extremity %s", earliestNewEvent.EventID())
|
||||||
return newEvents, true, nil
|
return newEvents, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue