Skip to content

refactor!: refine /transaction route response #5395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/iroha_torii/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,14 @@ impl Error {

match self {
Query(e) => Self::query_status_code(e),
AcceptTransaction(_) => StatusCode::BAD_REQUEST,
AcceptTransaction(err) => match err {
iroha_core::tx::AcceptTransactionFail::SignatureVerification(_) => StatusCode::UNAUTHORIZED,
iroha_core::tx::AcceptTransactionFail::UnexpectedGenesisAccountSignature => StatusCode::FORBIDDEN,
_ => StatusCode::BAD_REQUEST,
},
Config(_) | StatusSegmentNotFound(_) => StatusCode::NOT_FOUND,
PushIntoQueue(err) => match **err {
queue::Error::Full => StatusCode::INTERNAL_SERVER_ERROR,
queue::Error::Full => StatusCode::SERVICE_UNAVAILABLE,
_ => StatusCode::BAD_REQUEST,
},
#[cfg(feature = "telemetry")]
Expand Down
6 changes: 4 additions & 2 deletions crates/iroha_torii/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub async fn handle_transaction(
queue: Arc<Queue>,
state: Arc<State>,
tx: SignedTransaction,
) -> Result<()> {
) -> Result<impl IntoResponse> {
let (max_clock_drift, tx_limits) = {
let state_view = state.world.view();
let params = state_view.parameters();
Expand All @@ -44,7 +44,9 @@ pub async fn handle_transaction(

Box::new(err)
})
.map_err(Error::PushIntoQueue)
.map_err(Error::PushIntoQueue)?;

Ok((StatusCode::ACCEPTED, ()))
}

#[iroha_futures::telemetry_future]
Expand Down