Просмотр исходного кода

script/research/lotterysim/pid/pid.md: updated total_tokens() calculation

aggstam 3 лет назад
Родитель
Сommit
8415d6e522
1 измененных файлов с 6 добавлено и 7 удалено
  1. 6 7
      script/research/lotterysim/pid/pid.md

+ 6 - 7
script/research/lotterysim/pid/pid.md

@@ -81,13 +81,12 @@ Pseudocode:
 /// is needed to progress the blockchain, we know that
 /// total tokens > 0, as genesis_tokens > 0.
 fn total_tokens() -> u64 {
-    // Retrieve existing blocks count, excluding genesis
-    let blocks = (blockchain.len() as u64) - 1;
-    // Retrieve longest fork length, to include those
-    // proposals in the calculation
-    let max_fork_length = longest_chain_length() as u64;
-    // Calculate rewarded slots
-    let rewarded_slots = blocks + max_fork_length;
+    // Retrieve existing blocks count, excluding genesis,
+    // up until current slot
+    let blocks = blockchain.len_until(slot) - 1;
+    // Calculate rewarded slots, including previous slot
+    // longest fork proposals
+    let rewarded_slots = blocks + previous_slot.longest_fork_length;
     // Calculate rewarded tokens
     let rewarded_tokens = rewarded_slots * REWARD