Skip to content

Latest commit

 

History

History
111 lines (84 loc) · 1.81 KB

CM.md

File metadata and controls

111 lines (84 loc) · 1.81 KB

Connection Manager API

The libp2p daemon can optionally use a Connection Manager to keep connection counts in check. The daemon exposes the manager through the API specified in this document.

At the moment, this is a living document. As such, it will be susceptible to changes until stabilization.

Protocol Specification

Data Types

The data structures are defined in pb/p2pd.proto. All messages are varint-delimited. For the Connection Manager API, the relevant data types are:

  • ConnManagerRequest

All Connection Manager requests will be wrapped in a Request message with Type: CONNMANAGER. Responses from the daemon will be in the form of a Response.

Protocol Requests

Protocols described in pseudo-go. Items of the form [item, ...] are lists of many items.

Errors

Any response that may be an error, will take the form of:

Response{
  Type: ERROR,
  ErrorResponse: {
    Msg: <error message>,
  },
}

TAG_PEER

Clients can issue a TAG_PEER request to add a tag to a peer.

Client

Request{
  Type: CONNMANAGER,
  ConnManager: ConnManagerRequest{
    Type: TAG_PEER,
    Peer: <peer id>,
    Tag: <string>,
    Weight: <int>,
  },
}

Daemon Can return an error

Response{
  Type: OK,
}

UNTAG_PEER

Clients can issue a UNTAG_PEER request to remove a tag from a peer.

Client

Request{
  Type: CONNMANAGER,
  ConnManager: ConnManagerRequest{
    Type: UNTAG_PEER,
    Peer: <peer id>,
    Tag: <string>,
  },
}

Daemon Can return an error

Response{
  Type: OK,
}

TRIM

Clients can issue a TRIM request to trim open connections.

Client

Request{
  Type: CONNMANAGER,
  ConnManager: ConnManagerRequest{
    Type: TRIM,
  },
}

Daemon Can return an error

Response{
  Type: OK,
}