diff options
| -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(); |
