Skip to content

Commit

Permalink
initialize the btree maps
Browse files Browse the repository at this point in the history
  • Loading branch information
tbro committed Dec 11, 2024
1 parent d6304c1 commit 816f819
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion sequencer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ pub async fn init_node<P: SequencerPersistence, V: Versions>(
network_config.config.known_nodes_with_stake.clone(),
network_config.config.known_nodes_with_stake.clone(),
&instance_state,
Default::default(),
network_config.config.epoch_height,
)));

// Initialize the Libp2p network
Expand Down
47 changes: 22 additions & 25 deletions types/src/v0/impls/stake_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use hotshot_contract_adapter::stake_table::NodeInfoJf;
use hotshot_types::{
stake_table::StakeTableEntry,
traits::{
election::Membership, node_implementation::NodeType, signature_key::StakeTableEntryType,
election::Membership,
node_implementation::{ConsensusTime, NodeType},
signature_key::StakeTableEntryType,
},
PeerConfig,
};
Expand Down Expand Up @@ -195,24 +197,31 @@ impl StaticCommittee {
.filter(|entry| entry.stake() > U256::zero())
.collect();

// // Index the stake table by public key
// let indexed_stake_table: BTreeMap<PubKey, _> = members
// .iter()
// .map(|entry| (PubKey::public_key(entry), entry.clone()))
// .collect();
// Index the stake table by public key
let indexed_stake_table: HashMap<PubKey, _> = members
.iter()
.map(|entry| (PubKey::public_key(entry), entry.clone()))
.collect();

// // Index the stake table by public key
// let indexed_da_stake_table: BTreeMap<PubKey, _> = da_members
// .iter()
// .map(|entry| (PubKey::public_key(entry), entry.clone()))
// .collect();
// Wrap that in a map indexed by epoch
let indexed_stake_table: BTreeMap<Epoch, _> =
BTreeMap::from([(Epoch::genesis(), indexed_stake_table)]);

// Index the stake table by public key
let indexed_da_stake_table: HashMap<PubKey, _> = da_members
.iter()
.map(|entry| (PubKey::public_key(entry), entry.clone()))
.collect();
// Wrap that in a map indexed by epoch
let indexed_da_stake_table: BTreeMap<Epoch, _> =
BTreeMap::from([(Epoch::genesis(), indexed_da_stake_table)]);

Self {
eligible_leaders,
stake_table: HashSet::from_iter(members),
da_stake_table: HashSet::from_iter(da_members),
indexed_stake_table: BTreeMap::new(),
indexed_da_stake_table: BTreeMap::new(),
indexed_stake_table,
indexed_da_stake_table,
_epoch_size: epoch_size,
l1_client: instance_state.l1_client.clone(),
_contract_address: instance_state.chain_config.stake_table_contract,
Expand Down Expand Up @@ -295,18 +304,6 @@ impl Membership<SeqTypes> for Arc<RwLock<StaticCommittee>> {
.filter(|entry| entry.stake() > U256::zero())
.collect();

// // Index the stake table by public key
// let indexed_stake_table: BTreeMap<PubKey, _> = members
// .iter()
// .map(|entry| (PubKey::public_key(entry), entry.clone()))
// .collect();

// // Index the stake table by public key
// let indexed_da_stake_table: BTreeMap<PubKey, _> = da_members
// .iter()
// .map(|entry| (PubKey::public_key(entry), entry.clone()))
// .collect();

let committee = StaticCommittee {
eligible_leaders,
stake_table: HashSet::from_iter(members),
Expand Down

0 comments on commit 816f819

Please sign in to comment.