Skip to content

Commit

Permalink
BroadcastTransactionResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
zbuc committed Jan 10, 2024
1 parent 1c14fce commit d4cb44d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions crates/view/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ where
&mut self,
plan: &TransactionPlan,
) -> Pin<Box<dyn Future<Output = Result<WitnessData>> + Send + 'static>> {
// TODO: delete this code and move it into the view service.
// The caller shouldn't have to massage the transaction plan to make the request.

let request = WitnessRequest {
transaction_plan: Some(plan.clone().into()),
};
Expand Down Expand Up @@ -823,15 +820,17 @@ where
.await?
.into_inner();

if !await_detection {
// TODO: exit early here
}

while let Some(rsp) = rsp.try_next().await? {
match rsp.status {
Some(status) => match status {
pb::broadcast_transaction_response::Status::BroadcastSuccess(bs) => {
// TODO: stream a progress update
if !await_detection {
// Don't await confirmation, return immediately
return Ok((bs.id.ok_or_else(|| {
anyhow::anyhow!("BroadcastTransactionResponse broadcast success status message missing transaction id")
})?.try_into()?, 0u64));
}
}
pb::broadcast_transaction_response::Status::Confirmed(c) => {
return Ok((
Expand All @@ -853,7 +852,7 @@ where
}

Err(anyhow::anyhow!(
"should have received confirmed status or error"
"should have received status or error"
))
}
.boxed()
Expand Down

0 comments on commit d4cb44d

Please sign in to comment.