Skip to content

Commit

Permalink
Make transport initiator redial
Browse files Browse the repository at this point in the history
  • Loading branch information
i-hate-nicknames committed Jun 17, 2021
1 parent 6f340d9 commit 2a2a5f5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/transport/managed_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ func (mt *ManagedTransport) Serve(readCh chan<- routing.Packet) {
continue
}

// Only least significant edge is responsible for redialing.
if !mt.isLeastSignificantEdge() {
// Only initiator is responsible for redialing.
if !mt.isInitiator() {
continue
}

Expand Down Expand Up @@ -384,6 +384,11 @@ func (mt *ManagedTransport) redialLoop(ctx context.Context) error {
}

func (mt *ManagedTransport) isLeastSignificantEdge() bool {
sorted := SortEdges(mt.Entry.Edges[0], mt.Entry.Edges[1])
return sorted[0] == mt.n.LocalPK()
}

func (mt *ManagedTransport) isInitiator() bool {
return mt.Entry.EdgeIndex(mt.n.LocalPK()) == 0
}

Expand Down

0 comments on commit 2a2a5f5

Please sign in to comment.