diff options
author | necrashter | 2022-04-23 13:15:50 +0300 |
---|---|---|
committer | Yigit Sever | 2022-04-23 18:10:12 +0300 |
commit | cf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095 (patch) | |
tree | 02a6a163f037c323ce0bff59ea1c3fcbca8e1551 /src | |
parent | 426ce6b84fe6cba6fd4947fb54ba5d5837c65b73 (diff) | |
download | gradecoin-cf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095.tar.gz gradecoin-cf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095.tar.bz2 gradecoin-cf0a3cf8489cd84c7b2642c0bc7b50c5dee9a095.zip |
Add config property to DB
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 | } |