Complete the code to define the consensus mechanism used in Proof of Work.
consensus = "[1]"
The consensus mechanism for Proof of Work is called "Proof of Work" itself, where miners solve puzzles to validate transactions.
Complete the code to define the consensus mechanism used in Proof of Stake.
consensus = "[1]"
Proof of Stake uses the "Proof of Stake" consensus mechanism where validators are chosen based on their stake.
Fix the error in the code that calculates the mining reward for Proof of Work.
reward = base_reward [1] difficultyThe mining reward is typically calculated by multiplying the base reward by the difficulty factor.
Fill both blanks to complete the code that selects a validator in Proof of Stake based on stake and random chance.
selected_validator = validators[[1]] if stake [2] threshold else None
The validator is selected by index if their stake is greater than the threshold.
Fill all three blanks to complete the code that calculates the chance to validate a block in Proof of Stake.
chance = ([1] / total_stake) [2] random.random() and chance [3] threshold
The chance is calculated by multiplying user stake over total stake by a random number, then checking if chance is less than threshold.