diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/db.rs | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -10,6 +10,7 @@ | |||
10 | //! with their public keys, `metu_ids` and gradecoin balances. | 10 | //! with their public keys, `metu_ids` and gradecoin balances. |
11 | use crate::block::{Block, Fingerprint, Id, Transaction}; | 11 | use crate::block::{Block, Fingerprint, Id, Transaction}; |
12 | use crate::student::{MetuId, User, UserAtRest}; | 12 | use crate::student::{MetuId, User, UserAtRest}; |
13 | use crate::config::Config; | ||
13 | use log::debug; | 14 | use log::debug; |
14 | use parking_lot::RwLock; | 15 | use parking_lot::RwLock; |
15 | use std::{collections::HashMap, fs, io, path::PathBuf, sync::Arc}; | 16 | use 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 | } |