File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ func (t *spanningTree) selectNewParent() {
120120 var bestTime time.Time
121121 var bestPort types.SwitchPortID
122122 var bestAnn * rootAnnouncementWithTime
123+ var bestSeq types.Varu64
123124 portsToCheck := map [* Peer ]* rootAnnouncementWithTime {}
124125 for _ , p := range t .r .activePorts () {
125126 ann := p .lastAnnouncement ()
@@ -136,6 +137,7 @@ func (t *spanningTree) selectNewParent() {
136137 bestDist = hops
137138 bestPort = p .port
138139 bestTime = ann .at
140+ bestSeq = ann .Sequence
139141 bestAnn = ann
140142 }
141143 }
@@ -144,10 +146,13 @@ func (t *spanningTree) selectNewParent() {
144146 return ann .RootPublicKey .CompareTo (bestKey ) > 0
145147 })
146148 checkWithCondition (func (ann * rootAnnouncementWithTime , hops int ) bool {
147- return ann .RootPublicKey .CompareTo (bestKey ) > 0 && hops < bestDist
149+ return ann .RootPublicKey .CompareTo (bestKey ) == 0 && ann . Sequence > bestSeq
148150 })
149151 checkWithCondition (func (ann * rootAnnouncementWithTime , hops int ) bool {
150- return ann .RootPublicKey .CompareTo (bestKey ) == 0 && hops == bestDist && ann .at .Before (bestTime )
152+ return ann .RootPublicKey .CompareTo (bestKey ) == 0 && ann .Sequence == bestSeq && hops < bestDist
153+ })
154+ checkWithCondition (func (ann * rootAnnouncementWithTime , hops int ) bool {
155+ return ann .RootPublicKey .CompareTo (bestKey ) == 0 && ann .Sequence == bestSeq && hops == bestDist && ann .at .Before (bestTime )
151156 })
152157 if bestAnn != nil {
153158 t .parent .Store (bestPort )
You can’t perform that action at this time.
0 commit comments