Skip to content

Commit 898c222

Browse files
Seulgi Kimmergify[bot]
authored andcommitted
Describe the order of proposing blocks
1 parent 72e1b24 commit 898c222

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spec/Dynamic-Validator.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ It's a constant threshold to prevent the accounts with little delegations from b
7979
Current **DELEGATION_THRESHOLD** is `100,000`, which is 1% of the total CCS(`10,000,000`).
8080
It means there can be 100 valid candidates with the potential to be validators.
8181

82+
## The Order of Proposing Blocks
83+
The rate of becoming the block proposer is related to the number of delegations that the validator received.
84+
In other words, CodeChain allows the validator that receives more delegations to generate more blocks than others.
85+
86+
```rust
87+
let mut validators: Vec<(u64, u64, Account)> = // (Delegation, Deposit, Account)
88+
let mut proposers: Vec<Account> = vec![];
89+
validators.reverse_sort();
90+
let min_delegation = validator.last().0;
91+
while !validators.is_empty() {
92+
for (delegation, _, validator) in validators {
93+
proposers.push_back(validator);
94+
}
95+
validators.retain(|(delegation, _, _)| delegation > min_delegation);
96+
validators.for_each(|(mut delegation, _, _)| delegation -= min_delegation);
97+
}
98+
```
99+
82100
## Voting Power
83101
Each elected validators has different voting power.
84102
The voting power is based on the delegation that the validator received at the election.

0 commit comments

Comments
 (0)