defmodule MyspaceIPFS.Stats do @moduledoc """ MyspaceIPFS.Stats is where the stats commands of the IPFS API reside. """ import MyspaceIPFS.Api import MyspaceIPFS.Utils @typep okresult :: MyspaceIPFS.okresult() @typep opts :: MyspaceIPFS.opts() @typep name :: MyspaceIPFS.name() @doc """ Show some diagnostic information on the bitswap agent. ## Options https://docs.ipfs.io/reference/http/api/#api-v0-stats-bitswap human - , # Output human-readable numbers. verbose - , # Print extra information. """ @spec bitswap(opts) :: okresult def bitswap(opts \\ []) do post_query("/stats/bitswap", query: opts) end @doc """ Print ipfs bandwidth information. ## Options https://docs.ipfs.io/reference/http/api/#api-v0-stats-bw peer - , # Specify a peer to print bandwidth for. proto - , # Specify a protocol to print bandwidth for. poll - , # Poll for stats. interval - , # Time interval to poll. Default: 1s. """ @spec bw(opts) :: okresult def bw(opts \\ []) do post_query("/stats/bw", query: opts) end @doc """ Return the statistics about the nodes DHT(s). ## Parameters dht - , # The name of the DHT to query. # "wanserver", "lanserver", "lan" or "wan". """ @spec dht(name) :: MyspaceIPFS.okmapped() def dht(name) do post_query("/stats/dht?arg=#{name}") |> handle_plain_response() end @doc """ Returns statistics about the node's (re)provider system. """ @spec provide() :: okresult def provide do post_query("/stats/provide") |> handle_json_response() end @doc """ Get stats for the currently running repo. ## Options https://docs.ipfs.io/reference/http/api/#api-v0-stats-repo human - , # Output human-readable numbers. size-only - , # Only report the RepoSize. """ @spec repo(opts) :: okresult def repo(opts \\ []) do post_query("/stats/repo", query: opts) |> handle_json_response() end end