diff options
author | necrashter | 2022-04-23 02:21:47 +0300 |
---|---|---|
committer | Yigit Sever | 2022-04-23 10:58:48 +0300 |
commit | 981e340977477d52374458fa9d5a0ac7db62b971 (patch) | |
tree | 9e389a4b48f5d84b27b51310c4f8304746c83211 | |
parent | 1ae69f37e13cb3fa99416c5e02182468d0189cb4 (diff) | |
download | gradecoin-981e340977477d52374458fa9d5a0ac7db62b971.tar.gz gradecoin-981e340977477d52374458fa9d5a0ac7db62b971.tar.bz2 gradecoin-981e340977477d52374458fa9d5a0ac7db62b971.zip |
Fix coinbase block rewards
-rw-r--r-- | src/handlers.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index 23adffb..e31a4ad 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -548,11 +548,11 @@ pub async fn propose_block( | |||
548 | let mut users_store = RwLockUpgradableReadGuard::upgrade(users_store); | 548 | let mut users_store = RwLockUpgradableReadGuard::upgrade(users_store); |
549 | 549 | ||
550 | // Reward the block proposer | 550 | // Reward the block proposer |
551 | let coinbase_fingerprint = new_block.transaction_list.get(0).unwrap(); | 551 | // All unwrap calls here are guaranteed to succeed because they are already checked above |
552 | 552 | // See: internal_user_fingerprint, internal_user | |
553 | if let Some(coinbase_user) = users_store.get_mut(coinbase_fingerprint) { | 553 | let coinbase = pending_transactions.get(&new_block.transaction_list[0]).unwrap(); |
554 | coinbase_user.balance += BLOCK_REWARD; | 554 | let mut coinbase_user = users_store.get_mut(&coinbase.source).unwrap(); |
555 | } | 555 | coinbase_user.balance += BLOCK_REWARD; |
556 | 556 | ||
557 | let mut holding: HashMap<String, Transaction> = HashMap::new(); | 557 | let mut holding: HashMap<String, Transaction> = HashMap::new(); |
558 | 558 | ||