diff options
author | necrashter | 2022-04-23 17:17:18 +0300 |
---|---|---|
committer | Yigit Sever | 2022-04-23 18:10:12 +0300 |
commit | d2354a6b8af567afab7873645f6878f39d0de3fd (patch) | |
tree | a69dc6163c3f96ff1453dbc62e6641682636e674 /src | |
parent | f53292861c382484ce13d7af98e288bda97c55d0 (diff) | |
download | gradecoin-d2354a6b8af567afab7873645f6878f39d0de3fd.tar.gz gradecoin-d2354a6b8af567afab7873645f6878f39d0de3fd.tar.bz2 gradecoin-d2354a6b8af567afab7873645f6878f39d0de3fd.zip |
Config struct documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/config.rs b/src/config.rs index 7a524fc..28c63be 100644 --- a/src/config.rs +++ b/src/config.rs | |||
@@ -7,28 +7,50 @@ use log::{error, info}; | |||
7 | /// Configuration for a single network | 7 | /// Configuration for a single network |
8 | #[derive(Debug, Serialize, Deserialize, Clone, Default)] | 8 | #[derive(Debug, Serialize, Deserialize, Clone, Default)] |
9 | pub struct Config { | 9 | pub struct Config { |
10 | // Name of the network | 10 | /// Name of the network |
11 | pub name: String, | 11 | pub name: String, |
12 | // URL prefix for this network, can be empty | 12 | |
13 | /// URL prefix for this network, can be empty | ||
14 | /// | ||
15 | /// For example, if url_prefix is `example`, register at | ||
16 | /// `gradecoin.xyz/example/register` | ||
13 | pub url_prefix: String, | 17 | pub url_prefix: String, |
14 | // CSV file that contains the list of users who can register | 18 | |
19 | /// CSV file that contains the list of users who can register | ||
20 | /// | ||
21 | /// Format of CSV file: | ||
22 | /// ``` | ||
23 | /// User ID, Password | ||
24 | /// e123456,register_password | ||
25 | /// e123456,register_password | ||
26 | /// ``` | ||
27 | /// First line is ignored. | ||
15 | pub preapproved_users: String, | 28 | pub preapproved_users: String, |
16 | // Valid blocks should have this many transactions | 29 | |
30 | /// Valid blocks should have this many transactions | ||
17 | pub block_transaction_count: u8, | 31 | pub block_transaction_count: u8, |
18 | // How many zero hexadecimal characters should a correct hash start with? | 32 | |
33 | /// How many zero hexadecimal characters should a correct hash start with? | ||
19 | pub hash_zeros: u8, | 34 | pub hash_zeros: u8, |
20 | // Inital registration bonus | 35 | |
36 | /// Inital registration bonus | ||
21 | pub register_bonus: u16, | 37 | pub register_bonus: u16, |
22 | // Coinbase reward | 38 | |
39 | /// Coinbase reward | ||
23 | pub block_reward: u16, | 40 | pub block_reward: u16, |
24 | // Transaction amount limit | 41 | |
42 | /// Transaction amount upper limit | ||
25 | pub tx_upper_limit: u16, | 43 | pub tx_upper_limit: u16, |
44 | |||
45 | /// Transaction amount lower limit | ||
26 | pub tx_lower_limit: u16, | 46 | pub tx_lower_limit: u16, |
27 | // Transaction traffic reward | 47 | |
48 | /// Transaction traffic reward | ||
28 | pub tx_traffic_reward: u16, | 49 | pub tx_traffic_reward: u16, |
29 | } | 50 | } |
30 | 51 | ||
31 | impl Config { | 52 | impl Config { |
53 | /// Read the configuration from a given `.yaml` file. | ||
32 | pub fn read(filename: &str) -> Option<Self> { | 54 | pub fn read(filename: &str) -> Option<Self> { |
33 | let file = match std::fs::File::open(filename) { | 55 | let file = match std::fs::File::open(filename) { |
34 | Ok(f) => f, | 56 | Ok(f) => f, |