From a425a38e29d8a3235e991504d7e80ac9de8900a2 Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Thu, 10 Nov 2022 21:51:51 +0530 Subject: [PATCH] change connection initiation direction --- markets/idxprov/mesh.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/markets/idxprov/mesh.go b/markets/idxprov/mesh.go index 706115a25..e69e213ad 100644 --- a/markets/idxprov/mesh.go +++ b/markets/idxprov/mesh.go @@ -38,10 +38,13 @@ func (mc Libp2pMeshCreator) Connect(ctx context.Context) error { return fmt.Errorf("failed to fetch full node listen addrs, err: %w", err) } - // Connect to the full node, ask it to protect the connection and protect the connection on - // markets end too. - if err := mc.marketsHost.Connect(ctx, faddrs); err != nil { - return fmt.Errorf("failed to connect index provider host with the full node: %w", err) + // Connect from the full node, ask it to protect the connection and protect the connection on + // markets end too. Connection is initiated form full node to avoid the need to expose libp2p port on full node + if err := mc.fullnodeApi.NetConnect(ctx, peer.AddrInfo{ + ID: mc.marketsHost.ID(), + Addrs: mc.marketsHost.Addrs(), + }); err != nil { + return fmt.Errorf("failed to connect to index provider host from full node: %w", err) } mc.marketsHost.ConnManager().Protect(faddrs.ID, protectTag)