From 647967f271d356c3d309ab24ca96fd09f4c87829 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sat, 23 Apr 2022 11:04:52 +0300 Subject: Add logging to coinbase rewards --- src/handlers.rs | 1 + src/student.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/handlers.rs b/src/handlers.rs index e31a4ad..736ad29 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -553,6 +553,7 @@ pub async fn propose_block( let coinbase = pending_transactions.get(&new_block.transaction_list[0]).unwrap(); let mut coinbase_user = users_store.get_mut(&coinbase.source).unwrap(); coinbase_user.balance += BLOCK_REWARD; + debug!("{} block reward went to {:?} for mining the block", BLOCK_REWARD, coinbase_user); let mut holding: HashMap = HashMap::new(); diff --git a/src/student.rs b/src/student.rs index 2b9c5bd..b6d99cd 100644 --- a/src/student.rs +++ b/src/student.rs @@ -24,6 +24,12 @@ pub struct User { pub is_bot: bool, } +impl fmt::Display for User { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.user_id) + } +} + #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct MetuId { id: Id, -- cgit v1.2.3-70-g09d2