From 2a2a5f55f7e689fd73ff7b572b6631c45e97667b Mon Sep 17 00:00:00 2001 From: Never M Date: Thu, 17 Jun 2021 16:20:39 +0300 Subject: [PATCH] Make transport initiator redial --- pkg/transport/managed_transport.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/transport/managed_transport.go b/pkg/transport/managed_transport.go index 34334f851..9b5dae6cb 100644 --- a/pkg/transport/managed_transport.go +++ b/pkg/transport/managed_transport.go @@ -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 } @@ -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 }