mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-01-04 06:33:11 +00:00
rename Round.members -> Round.proposers
This commit is contained in:
parent
ff848a20c4
commit
7218991f31
@ -45,9 +45,9 @@ func skips(blck: Block, round: uint64, author: CommitteeMember): bool =
|
||||
func updateSkipped(validator: Validator, supporter: Block) =
|
||||
if round =? validator.rounds.latest.find(supporter.round) and
|
||||
previous =? round.previous:
|
||||
for member in previous.members:
|
||||
let slot = previous[member]
|
||||
if supporter.skips(previous.number, member):
|
||||
for proposer in previous.proposers:
|
||||
let slot = previous[proposer]
|
||||
if supporter.skips(previous.number, proposer):
|
||||
let author = supporter.author
|
||||
let stake = validator.committee.stake(author)
|
||||
slot.skipBy(author, stake)
|
||||
|
||||
@ -32,14 +32,14 @@ func next*(round: Round): auto =
|
||||
func `[]`*(round: Round, member: CommitteeMember): auto =
|
||||
round.slots[int(member)]
|
||||
|
||||
iterator members*(round: Round): CommitteeMember =
|
||||
iterator proposers*(round: Round): CommitteeMember =
|
||||
let length = round.slots.len
|
||||
let offset = (round.number mod length.uint64).int
|
||||
for index in 0..<length:
|
||||
yield CommitteeMember((offset + index) mod length)
|
||||
|
||||
iterator slots*(round: Round): auto =
|
||||
for member in round.members:
|
||||
for member in round.proposers:
|
||||
yield round[member]
|
||||
|
||||
iterator proposals*(round: Round): auto =
|
||||
|
||||
@ -120,18 +120,18 @@ suite "Validator Round":
|
||||
check third.previous == none Round
|
||||
check third.next == none Round
|
||||
|
||||
test "members are ordered round-robin for each round":
|
||||
test "proposers are ordered round-robin for each round":
|
||||
var round: Round
|
||||
round = Round.new(0, 4)
|
||||
check toSeq(round.members) == @[0, 1, 2, 3].mapIt(CommitteeMember(it))
|
||||
check toSeq(round.proposers) == @[0, 1, 2, 3].mapIt(CommitteeMember(it))
|
||||
round = Round.new(1, 4)
|
||||
check toSeq(round.members) == @[1, 2, 3, 0].mapIt(CommitteeMember(it))
|
||||
check toSeq(round.proposers) == @[1, 2, 3, 0].mapIt(CommitteeMember(it))
|
||||
round = Round.new(2, 4)
|
||||
check toSeq(round.members) == @[2, 3, 0, 1].mapIt(CommitteeMember(it))
|
||||
check toSeq(round.proposers) == @[2, 3, 0, 1].mapIt(CommitteeMember(it))
|
||||
round = Round.new(3, 4)
|
||||
check toSeq(round.members) == @[3, 0, 1, 2].mapIt(CommitteeMember(it))
|
||||
check toSeq(round.proposers) == @[3, 0, 1, 2].mapIt(CommitteeMember(it))
|
||||
round = Round.new(4, 4)
|
||||
check toSeq(round.members) == @[0, 1, 2, 3].mapIt(CommitteeMember(it))
|
||||
check toSeq(round.proposers) == @[0, 1, 2, 3].mapIt(CommitteeMember(it))
|
||||
|
||||
test "slots are ordered round-robin too":
|
||||
let round = Round.new(2, 4)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user