bitcoind_request/command/
get_connection_count.rs

1/*
2getconnectioncount
3
4Returns the number of connections to other nodes.
5
6Result:
7n    (numeric) The connection count
8
9Examples:
10> bitcoin-cli getconnectioncount
11> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getconnectioncount", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
12*/
13use crate::command::CallableCommand;
14use crate::{client::Client, command::request::request};
15use serde::{Deserialize, Serialize};
16use serde_json::value::RawValue;
17
18pub struct GetConnectionCountCommand {}
19impl GetConnectionCountCommand {
20    pub fn new() -> Self {
21        GetConnectionCountCommand {}
22    }
23}
24
25#[derive(Serialize, Deserialize, Debug)]
26pub struct GetConnectionCountCommandResponse(pub u64);
27
28impl CallableCommand for GetConnectionCountCommand {
29    type Response = GetConnectionCountCommandResponse;
30    fn call(&self, client: &Client) -> Result<Self::Response, jsonrpc::Error> {
31        let command = "getconnectioncount";
32        let params: Vec<Box<RawValue>> = vec![];
33        let r = request(client, command, params);
34        let response: GetConnectionCountCommandResponse = r.result()?;
35        Ok(response)
36    }
37}