peers method

Future<Map<String, dynamic>> peers({
  1. bool? verbose,
  2. bool? streams,
  3. bool? latency,
  4. bool? direction,
})

List peers with open connections. /api/v0/swarm/peers

Optional arguments:

  • verbose bool: Display all extra information.
  • streams bool: Also list information about open streams for each peer.
  • latency bool: Also list information about latency to each peer.
  • direction bool: Also list information about the direction of connection.

Response:

{
  "Peers": [
    {
      "Addr": "<string>",
      "Direction": "<int>",
      "Latency": "<string>",
      "Muxer": "<string>",
      "Peer": "<string>",
      "Streams": [
        {
          "Protocol": "<string>"
        },
      ]
    }
  ],
  "StatusCode": "<statusCode>",
  "StatusMessage": "<statusMessage>"
}

See more: https://docs.ipfs.io/reference/http/api/#api-v0-swarm-peers

Implementation

Future<Map<String, dynamic>> peers(
    {bool? verbose, bool? streams, bool? latency, bool? direction}) async {
  Response? res = await _post(
    Ipfs.dio,
    url: "${Ipfs.url}/swarm/peers",
    queryParameters: {
      if (verbose != null) "verbose": verbose,
      if (streams != null) "streams": streams,
      if (latency != null) "latency": latency,
      if (direction != null) "direction": direction,
    },
  );

  return _interceptDioResponse(res, expectsResponseBody: true);
}