Unverified Commit 81b1cfea authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #6171 from ipfs/fix/6164

feat(coreapi): tag all explicit connect requests in the connection manager
parents c126cd32 d21bb1ee
......@@ -27,6 +27,10 @@ type connInfo struct {
peer peer.ID
}
// tag used in the connection manager when explicitly connecting to a peer.
const connectionManagerTag = "user-connect"
const connectionManagerWeight = 100
func (api *SwarmAPI) Connect(ctx context.Context, pi pstore.PeerInfo) error {
if api.peerHost == nil {
return coreiface.ErrOffline
......@@ -36,7 +40,12 @@ func (api *SwarmAPI) Connect(ctx context.Context, pi pstore.PeerInfo) error {
swrm.Backoff().Clear(pi.ID)
}
return api.peerHost.Connect(ctx, pi)
if err := api.peerHost.Connect(ctx, pi); err == nil {
return err
}
api.peerHost.ConnManager().TagPeer(pi.ID, connectionManagerTag, connectionManagerWeight)
return nil
}
func (api *SwarmAPI) Disconnect(ctx context.Context, addr ma.Multiaddr) error {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment