aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornecrashter2022-04-23 13:15:50 +0300
committerYigit Sever2022-04-23 18:10:12 +0300
commitcf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095 (patch)
tree02a6a163f037c323ce0bff59ea1c3fcbca8e1551
parent426ce6b84fe6cba6fd4947fb54ba5d5837c65b73 (diff)
downloadgradecoin-cf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095.tar.gz
gradecoin-cf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095.tar.bz2
gradecoin-cf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095.zip
Add config property to DB
-rw-r--r--src/db.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/db.rs b/src/db.rs
index a00def5..85d43a0 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -10,6 +10,7 @@
10//! with their public keys, `metu_ids` and gradecoin balances. 10//! with their public keys, `metu_ids` and gradecoin balances.
11use crate::block::{Block, Fingerprint, Id, Transaction}; 11use crate::block::{Block, Fingerprint, Id, Transaction};
12use crate::student::{MetuId, User, UserAtRest}; 12use crate::student::{MetuId, User, UserAtRest};
13use crate::config::Config;
13use log::debug; 14use log::debug;
14use parking_lot::RwLock; 15use parking_lot::RwLock;
15use std::{collections::HashMap, fs, io, path::PathBuf, sync::Arc}; 16use std::{collections::HashMap, fs, io, path::PathBuf, sync::Arc};
@@ -21,6 +22,7 @@ pub struct Db {
21 pub blockchain: Arc<RwLock<Block>>, 22 pub blockchain: Arc<RwLock<Block>>,
22 pub pending_transactions: Arc<RwLock<HashMap<Id, Transaction>>>, 23 pub pending_transactions: Arc<RwLock<HashMap<Id, Transaction>>>,
23 pub users: Arc<RwLock<HashMap<Fingerprint, User>>>, 24 pub users: Arc<RwLock<HashMap<Fingerprint, User>>>,
25 pub config: Config,
24 preapproved_users: Vec<MetuId>, 26 preapproved_users: Vec<MetuId>,
25} 27}
26 28
@@ -44,6 +46,14 @@ impl Db {
44 blockchain: Arc::new(RwLock::new(Block::default())), 46 blockchain: Arc::new(RwLock::new(Block::default())),
45 pending_transactions: Arc::new(RwLock::new(HashMap::new())), 47 pending_transactions: Arc::new(RwLock::new(HashMap::new())),
46 users: Arc::new(RwLock::new(users)), 48 users: Arc::new(RwLock::new(users)),
49 config: Config {
50 block_transaction_count: 4,
51 register_bonus: 100,
52 block_reward: 4,
53 tx_upper_limit: 4,
54 tx_lower_limit: 1,
55 tx_traffic_reward: 1,
56 },
47 preapproved_users, 57 preapproved_users,
48 } 58 }
49 } 59 }