From 471b7a537f3fee2b481aabc21baef8e97476d978 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Mon, 23 Oct 2023 09:17:04 +0200 Subject: [PATCH] fix: start_primary --- node/bft/examples/simple_node.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index ed18c63c08..b9c869c983 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -169,17 +169,24 @@ pub async fn start_bft( /// Starts the primary instance. pub async fn start_primary( - _node_id: u16, - _num_nodes: u16, - _peers: HashMap, + node_id: u16, + num_nodes: u16, + peers: HashMap, ) -> Result<(Primary, PrimarySender)> { - /* // Initialize the primary channels. let (sender, receiver) = init_primary_channels(); // Initialize the components. let (committee, account) = initialize_components(node_id, num_nodes)?; - // Initialize the mock ledger service. - let ledger = Arc::new(MockLedgerService::new(committee)); + let gen_key = account.private_key(); + let public_balance_per_validator = + (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + let mut balances = IndexMap::, u64>::new(); + for address in committee.members().keys() { + balances.insert(*address, public_balance_per_validator); + } + let mut rng = TestRng::default(); + let gen_ledger = genesis_ledger(*gen_key, committee.clone(), balances.clone(), &mut rng); + let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger)); // Initialize the storage. let storage = Storage::new(ledger.clone(), MAX_GC_ROUNDS); // Initialize the gateway IP and dev mode. @@ -197,8 +204,6 @@ pub async fn start_primary( handle_signals(&primary); // Return the primary instance. Ok((primary, sender)) - */ - todo!() } pub type CurrentLedger = Ledger>;