Skip to content

Commit 899d02f

Browse files
fix seed call
1 parent 5738779 commit 899d02f

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

chain/src/actors/application/supervisor.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use alto_types::leader_index;
22
use commonware_consensus::{
3-
threshold_simplex::types::View, Supervisor as Su, ThresholdSupervisor as TSu,
3+
threshold_simplex::types::{Seed, View},
4+
Supervisor as Su, ThresholdSupervisor as TSu,
45
};
56
use commonware_cryptography::{
67
bls12381::primitives::{
@@ -66,8 +67,8 @@ impl TSu for Supervisor {
6667
type Identity = poly::Public;
6768
type Share = group::Share;
6869

69-
fn leader(&self, _: Self::Index, seed: Self::Seed) -> Option<Self::PublicKey> {
70-
let seed = seed.serialize();
70+
fn leader(&self, view: Self::Index, seed: Self::Seed) -> Option<Self::PublicKey> {
71+
let seed = Seed::new(view, seed);
7172
let index = leader_index(&seed, self.participants.len());
7273
Some(self.participants[index].clone())
7374
}

types/src/consensus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use commonware_consensus::threshold_simplex::types::Seed;
33
use commonware_utils::modulo;
44

55
/// The leader for a given seed is determined by the modulo of the seed with the number of participants.
6-
pub fn leader_index(seed: Seed, participants: usize) -> usize {
6+
pub fn leader_index(seed: &Seed, participants: usize) -> usize {
77
let signature = seed.signature.encode().freeze();
88
modulo(&signature, participants as u64) as usize
99
}

types/src/wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ pub fn parse_block(bytes: Vec<u8>) -> JsValue {
124124
#[wasm_bindgen]
125125
pub fn leader_index(seed: Vec<u8>, participants: usize) -> usize {
126126
let seed = Seed::decode(seed.as_ref()).unwrap();
127-
compute_leader_index(seed, participants)
127+
compute_leader_index(&seed, participants)
128128
}

0 commit comments

Comments
 (0)