1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use abscissa_core::path::PathBuf;
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
use std::time::Duration;
use tendermint_light_client::light_client;
use tendermint_light_client::types::{PeerId, TrustThreshold};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct LightNodeConfig {
pub trust_threshold: TrustThreshold,
pub trusting_period: Duration,
pub clock_drift: Duration,
pub rpc_config: RpcConfig,
pub light_clients: Vec<LightClientConfig>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct LightClientConfig {
pub address: tendermint::net::Address,
pub peer_id: PeerId,
pub db_path: PathBuf,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RpcConfig {
pub listen_addr: SocketAddr,
pub request_timeout: Duration,
}
impl Default for LightClientConfig {
fn default() -> Self {
Self {
address: "tcp://127.0.0.1:26657".parse().unwrap(),
peer_id: "BADFADAD0BEFEEDC0C0ADEADBEEFC0FFEEFACADE".parse().unwrap(),
db_path: "./lightstore/BADFADAD0BEFEEDC0C0ADEADBEEFC0FFEEFACADE"
.parse()
.unwrap(),
}
}
}
impl Default for LightNodeConfig {
fn default() -> Self {
Self {
trusting_period: Duration::from_secs(864_000),
trust_threshold: TrustThreshold {
numerator: 1,
denominator: 3,
},
clock_drift: Duration::from_secs(1),
rpc_config: RpcConfig {
listen_addr: "127.0.0.1:8888".parse().unwrap(),
request_timeout: Duration::from_secs(60),
},
light_clients: vec![LightClientConfig::default()],
}
}
}
impl From<LightNodeConfig> for light_client::Options {
fn from(lnc: LightNodeConfig) -> Self {
Self {
trust_threshold: lnc.trust_threshold,
trusting_period: lnc.trusting_period,
clock_drift: lnc.clock_drift,
}
}
}