Skip to content

Commit

Permalink
make_benchmark_block_proposals now returns BlockProposals
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-ds committed Feb 6, 2025
1 parent 66caa6a commit 89a96c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions linera-client/src/client_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ where
key_pairs: &HashMap<ChainId, KeyPair>,
transactions_per_block: usize,
fungible_application_id: Option<ApplicationId>,
) -> Vec<RpcMessage> {
) -> Vec<BlockProposal> {
let mut proposals = Vec::new();
let mut next_recipient = *key_pairs
.iter()
Expand Down Expand Up @@ -921,7 +921,7 @@ where
block.clone(),
key_pair,
);
proposals.push(RpcMessage::BlockProposal(Box::new(proposal)));
proposals.push(proposal);
next_recipient = chain.chain_id;
}
proposals
Expand Down
30 changes: 16 additions & 14 deletions linera-service/src/linera/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,27 +809,29 @@ impl Runnable for Job {
let num_proposal = proposals.len();

let mut join_set = JoinSet::new();
for rpc_msg in &proposals {
if let RpcMessage::BlockProposal(proposal) = rpc_msg {
let block = proposal.content.block.clone();
let client = context.client.clone();
join_set.spawn(async move {
let executed_block = client
.local_node()
.stage_block_execution(block, None)
.await?
.0;
let value = Hashed::new(ConfirmedBlock::new(executed_block));
Ok::<_, anyhow::Error>((value.hash(), value))
});
}
for proposal in &proposals {
let block = proposal.content.block.clone();
let client = context.client.clone();
join_set.spawn(async move {
let executed_block = client
.local_node()
.stage_block_execution(block, None)
.await?
.0;
let value = Hashed::new(ConfirmedBlock::new(executed_block));
Ok::<_, anyhow::Error>((value.hash(), value))
});
}
let values = join_set
.join_all()
.await
.into_iter()
.collect::<Result<HashMap<_, _>, _>>()?;

let proposals = proposals
.into_iter()
.map(|proposal| RpcMessage::BlockProposal(Box::new(proposal)))
.collect::<Vec<_>>();
let responses = context.mass_broadcast("block proposals", proposals).await;
let votes = responses
.into_iter()
Expand Down

0 comments on commit 89a96c3

Please sign in to comment.