From baace892ff174ec0429a7c83e0b0a032266e065f Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Mon, 26 Apr 2021 03:17:56 +0300 Subject: fix coinbase --- src/handlers.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/handlers.rs b/src/handlers.rs index b8b20d7..349d03b 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -547,6 +547,13 @@ pub async fn propose_block( let mut pending_transactions = RwLockUpgradableReadGuard::upgrade(pending_transactions); let mut users_store = RwLockUpgradableReadGuard::upgrade(users_store); + // Reward the block proposer + let coinbase_fingerprint = new_block.transaction_list.get(0).unwrap(); + + if let Some(coinbase_user) = users_store.get_mut(coinbase_fingerprint) { + coinbase_user.balance += BLOCK_REWARD; + } + // Play out the transactions for fingerprint in new_block.transaction_list.iter() { if let Some(transaction) = pending_transactions.remove(fingerprint) { @@ -577,13 +584,6 @@ pub async fn propose_block( } } } - - // Reward the block proposer - let coinbase_fingerprint = new_block.transaction_list.get(0).unwrap(); - - if let Some(coinbase_user) = users_store.get_mut(coinbase_fingerprint) { - coinbase_user.balance += BLOCK_REWARD; - } } let block_json = serde_json::to_string(&new_block).unwrap(); -- cgit v1.2.3-70-g09d2