Skip to content

Commit

Permalink
Handle None case for transaction flow
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed May 6, 2024
1 parent 7a509d6 commit b5a885b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions crates/bioauth-flow-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,57 +381,65 @@ where
.map_err(AuthenticateError::BioauthTx).map_err(errtype)?.fuse();

tokio::spawn(async move {
while let Some(tx_status) = watch.next().await {
match tx_status {
TransactionStatus::Finalized((block_hash, _))=> {
loop {
let maybe_tx_status = watch.next().await;

match maybe_tx_status {
Some(TransactionStatus::Finalized((block_hash, _)))=> {
info!(
message = "Bioauth flow - authenticate transaction is in finalized block",
%block_hash,
);
break
},
TransactionStatus::Retracted(block_hash) => {
Some(TransactionStatus::Retracted(block_hash)) => {
error!(
message = "Bioauth flow - the block this transaction was included in has been retracted",
%block_hash,
);
break
},
TransactionStatus::Usurped(_) => {
Some(TransactionStatus::Usurped(_)) => {
error!(
"Bioauth flow - transaction has been replaced in the pool, by another transaction",
);
break
},
TransactionStatus::Dropped => {
Some(TransactionStatus::Dropped) => {
error!(
"Bioauth flow - transaction has been dropped from the pool because of the limit",
);
break
},
TransactionStatus::FinalityTimeout(_) => {
Some(TransactionStatus::FinalityTimeout(_)) => {
error!(
"Bioauth flow - maximum number of finality watchers has been reached, old watchers are being removed",
);
break
},
TransactionStatus::Invalid => {
Some(TransactionStatus::Invalid) => {
error!(
"Bioauth flow - transaction is no longer valid in the current state",
);
break
},
TransactionStatus::Ready => info!("Bioauth flow - authenticate transaction is in ready queue"),
TransactionStatus::Broadcast(_) => {
Some(TransactionStatus::Ready) => info!("Bioauth flow - authenticate transaction is in ready queue"),
Some(TransactionStatus::Broadcast(_)) => {
info!("Bioauth flow - authenticate transaction is broadcasted");
},
TransactionStatus::InBlock((block_hash, _)) => {
Some(TransactionStatus::InBlock((block_hash, _))) => {
info!(
message = "Bioauth flow - authenticate transaction is in block",
%block_hash,
);
},
TransactionStatus::Future => info!("Bioauth flow - authenticate transaction is in future queue"),
Some(TransactionStatus::Future) => info!("Bioauth flow - authenticate transaction is in future queue"),
None => {
error!(
"Bioauth flow - unexpected transaction flow interruption",
);
break
}
}
}

Expand Down

0 comments on commit b5a885b

Please sign in to comment.