changes to mesh creation code
This commit is contained in:
parent
daac7f2988
commit
eb8296120b
@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
|
||||
"github.com/filecoin-project/lotus/api/v1api"
|
||||
@ -27,19 +25,14 @@ type Libp2pMeshCreator struct {
|
||||
func (mc Libp2pMeshCreator) Connect(ctx context.Context) error {
|
||||
faddrs, err := mc.fullnodeApi.NetAddrsListen(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// if we already have a connection to the full node, there's nothing to do here
|
||||
if mc.idxProvHost.Network().Connectedness(faddrs.ID) == network.Connected {
|
||||
return nil
|
||||
return fmt.Errorf("failed to fetch full node listen addrs, err: %w", err)
|
||||
}
|
||||
|
||||
// otherwise, connect to the full node, ask it to protect the connection and protect the connection on our end too
|
||||
if err := mc.idxProvHost.Connect(ctx, faddrs); err != nil {
|
||||
return fmt.Errorf("failed to connect index provider host with the full node: %w", err)
|
||||
}
|
||||
mc.idxProvHost.ConnManager().Protect(faddrs.ID, "markets")
|
||||
mc.idxProvHost.ConnManager().Protect(faddrs.ID, "index-provider-gossipsub")
|
||||
if err := mc.fullnodeApi.NetProtectAdd(ctx, []peer.ID{mc.idxProvHost.ID()}); err != nil {
|
||||
return fmt.Errorf("failed to call NetProtectAdd on the full node, err: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user