lisk_api_rust_client/api/
node.rs

1use api::models::{ForgingStats, ForgingStatus, NodeConstants, NodeStatus};
2use api::Result;
3use http::client::Client;
4use std::collections::HashMap;
5
6pub struct Node {
7    client: Client,
8}
9
10impl Node {
11    pub fn new(client: Client) -> Node {
12        Node { client }
13    }
14
15    pub fn status(&self) -> Result<NodeStatus> {
16        self.client.get("node/status")
17    }
18
19    pub fn constants(&self) -> Result<NodeConstants> {
20        self.client.get("node/constants")
21    }
22
23    pub fn forging_status(&self, public_key: &str) -> Result<ForgingStats> {
24        let endpoint = format!("node/status/forging?publicKey={}", public_key);
25        self.client.get(&endpoint)
26    }
27
28    pub fn update_forging_status(
29        &self,
30        data: Option<HashMap<&str, &str>>,
31    ) -> Result<ForgingStatus> {
32        self.client.post("node/status/forging", data)
33    }
34}