ergo_rest/
node_conf.rs

1use std::time::Duration;
2
3use crate::reqwest::header::HeaderValue;
4use ergo_chain_types::PeerAddr;
5
6/// Ergo node configuration
7#[derive(PartialEq, Eq, Debug, Clone, Copy)]
8pub struct NodeConf {
9    /// Node address
10    pub addr: PeerAddr,
11    /// Node API key
12    pub api_key: Option<&'static str>,
13    /// Request timeout
14    pub timeout: Option<Duration>,
15}
16
17impl NodeConf {
18    /// Generate the value for api_key header key
19    pub fn get_node_api_header(&self) -> HeaderValue {
20        match self.api_key {
21            Some(api_key) => match HeaderValue::from_str(api_key) {
22                Ok(k) => k,
23                _ => HeaderValue::from_static("None"),
24            },
25            None => HeaderValue::from_static("None"),
26        }
27    }
28}