mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
Update comments in calculateLatest
This commit is contained in:
parent
7003be4559
commit
6e45fa082c
|
|
@ -261,8 +261,8 @@ func (u *latestEventsUpdater) calculateLatest(
|
||||||
var newLatest []types.StateAtEventAndReference
|
var newLatest []types.StateAtEventAndReference
|
||||||
|
|
||||||
// First of all, let's see if any of the existing forward extremities
|
// First of all, let's see if any of the existing forward extremities
|
||||||
// now have entries in the previous events table. If they do then they
|
// now have entries in the previous events table. If they do then we
|
||||||
// are no longer forward extremities.
|
// will no longer include them as forward extremities.
|
||||||
for _, l := range oldLatest {
|
for _, l := range oldLatest {
|
||||||
referenced, err := u.updater.IsReferenced(l.EventReference)
|
referenced, err := u.updater.IsReferenced(l.EventReference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -274,17 +274,22 @@ func (u *latestEventsUpdater) calculateLatest(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then check and see if our new event is already included in that set.
|
// Then check and see if our new event is already included in that set.
|
||||||
|
// This ordinarily won't happen but it covers the edge-case that we've
|
||||||
|
// already seen this event before and it's a forward extremity, so rather
|
||||||
|
// than adding a duplicate, we'll just return the set as complete.
|
||||||
for _, l := range newLatest {
|
for _, l := range newLatest {
|
||||||
if l.EventReference.EventID == newEvent.EventReference.EventID && bytes.Equal(l.EventReference.EventSHA256, newEvent.EventReference.EventSHA256) {
|
if l.EventReference.EventID == newEvent.EventReference.EventID && bytes.Equal(l.EventReference.EventSHA256, newEvent.EventReference.EventSHA256) {
|
||||||
// We've already referenced this event so we can just return
|
// We've already referenced this new event so we can just return
|
||||||
// the newly completed extremities at this point.
|
// the newly completed extremities at this point.
|
||||||
u.latest = newLatest
|
u.latest = newLatest
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the new event isn't already in the set then we'll check if it
|
// At this point we've processed the old extremities, and we've checked
|
||||||
// really should be.
|
// that our new event isn't already in that set. Therefore now we can
|
||||||
|
// check if our *new* event is a forward extremity, and if it is, add
|
||||||
|
// it in.
|
||||||
referenced, err := u.updater.IsReferenced(newEvent.EventReference)
|
referenced, err := u.updater.IsReferenced(newEvent.EventReference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to retrieve event reference for %q", newEvent.EventReference.EventID)
|
logrus.WithError(err).Errorf("Failed to retrieve event reference for %q", newEvent.EventReference.EventID)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue