diff options
author | Yigit Sever | 2021-04-26 03:17:56 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-26 03:17:56 +0300 |
commit | baace892ff174ec0429a7c83e0b0a032266e065f (patch) | |
tree | b5641a03339247f361faf57a62d64bf21efc8723 /src | |
parent | 95aeb141c1ca7188b1f23cf807b93a0457e20391 (diff) | |
download | gradecoin-baace892ff174ec0429a7c83e0b0a032266e065f.tar.gz gradecoin-baace892ff174ec0429a7c83e0b0a032266e065f.tar.bz2 gradecoin-baace892ff174ec0429a7c83e0b0a032266e065f.zip |
fix coinbase
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers.rs | 14 |
1 files 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( | |||
547 | let mut pending_transactions = RwLockUpgradableReadGuard::upgrade(pending_transactions); | 547 | let mut pending_transactions = RwLockUpgradableReadGuard::upgrade(pending_transactions); |
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 | ||
551 | let coinbase_fingerprint = new_block.transaction_list.get(0).unwrap(); | ||
552 | |||
553 | if let Some(coinbase_user) = users_store.get_mut(coinbase_fingerprint) { | ||
554 | coinbase_user.balance += BLOCK_REWARD; | ||
555 | } | ||
556 | |||
550 | // Play out the transactions | 557 | // Play out the transactions |
551 | for fingerprint in new_block.transaction_list.iter() { | 558 | for fingerprint in new_block.transaction_list.iter() { |
552 | if let Some(transaction) = pending_transactions.remove(fingerprint) { | 559 | if let Some(transaction) = pending_transactions.remove(fingerprint) { |
@@ -577,13 +584,6 @@ pub async fn propose_block( | |||
577 | } | 584 | } |
578 | } | 585 | } |
579 | } | 586 | } |
580 | |||
581 | // Reward the block proposer | ||
582 | let coinbase_fingerprint = new_block.transaction_list.get(0).unwrap(); | ||
583 | |||
584 | if let Some(coinbase_user) = users_store.get_mut(coinbase_fingerprint) { | ||
585 | coinbase_user.balance += BLOCK_REWARD; | ||
586 | } | ||
587 | } | 587 | } |
588 | 588 | ||
589 | let block_json = serde_json::to_string(&new_block).unwrap(); | 589 | let block_json = serde_json::to_string(&new_block).unwrap(); |