aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornecrashter2022-04-23 17:17:18 +0300
committerYigit Sever2022-04-23 18:10:12 +0300
commitd2354a6b8af567afab7873645f6878f39d0de3fd (patch)
treea69dc6163c3f96ff1453dbc62e6641682636e674
parentf53292861c382484ce13d7af98e288bda97c55d0 (diff)
downloadgradecoin-d2354a6b8af567afab7873645f6878f39d0de3fd.tar.gz
gradecoin-d2354a6b8af567afab7873645f6878f39d0de3fd.tar.bz2
gradecoin-d2354a6b8af567afab7873645f6878f39d0de3fd.zip
Config struct documentation
-rw-r--r--config.yaml2
-rw-r--r--src/config.rs40
2 files changed, 32 insertions, 10 deletions
diff --git a/config.yaml b/config.yaml
index e2f6b72..fe2502a 100644
--- a/config.yaml
+++ b/config.yaml
@@ -1,7 +1,7 @@
1# The name of the network 1# The name of the network
2name: mainnet 2name: mainnet
3# URL Prefix for this network 3# URL Prefix for this network
4# For example, url_prefix is "example", register at "gradecoin.xyz/example/register" 4# For example, if url_prefix is "example", register at "gradecoin.xyz/example/register"
5url_prefix: "" 5url_prefix: ""
6# List of users who can register 6# List of users who can register
7# CSV file: userID,password 7# CSV file: userID,password
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)]
9pub struct Config { 9pub 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
31impl Config { 52impl 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,