Skip to content

Commit

Permalink
[fix] remove pagination; address pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: VAmuzing <[email protected]>
  • Loading branch information
VAmuzing committed Jan 25, 2024
1 parent 2912298 commit 2a505ea
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 39 deletions.
33 changes: 5 additions & 28 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,31 +1000,27 @@ impl Client {
)
}

/// Find the original transaction in the pending local tx
/// queue. Should be used for an MST case. Takes pagination as
/// parameter.
/// Find the original transaction in the local pending tx queue.
/// Should be used for an MST case.
///
/// # Errors
/// - if subscribing to websocket fails
pub fn get_original_transactions_with_pagination(
/// - if sending request fails
pub fn get_original_matching_transactions(
&self,
transaction: &SignedTransaction,
retry_count: u32,
retry_in: Duration,
pagination: Pagination,
) -> Result<Vec<SignedTransaction>> {
let url = self
.torii_url
.join(crate::config::torii::MATCHING_PENDING_TRANSACTIONS)
.expect("Valid URI");
let pagination = pagination.into_query_parameters();
let body = transaction.encode();

for _ in 0..retry_count {
let response = DefaultRequestBuilder::new(HttpMethod::POST, url.clone())
.headers(self.headers.clone())
.header(http::header::CONTENT_TYPE, APPLICATION_JSON)
.params(pagination.clone())
.body(body.clone())
.build()?
.send()?;
Expand All @@ -1045,26 +1041,7 @@ impl Client {
));
}
}
Ok(vec![])
}

/// Find the original transaction in the local pending tx queue.
/// Should be used for an MST case.
///
/// # Errors
/// - if sending request fails
pub fn get_original_transactions(
&self,
transaction: &SignedTransaction,
retry_count: u32,
retry_in: Duration,
) -> Result<Vec<SignedTransaction>> {
self.get_original_transactions_with_pagination(
transaction,
retry_count,
retry_in,
Pagination::default(),
)
Ok(Vec::new())
}

/// Get value of config on peer
Expand Down
7 changes: 3 additions & 4 deletions client/tests/integration/multisignature_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ fn multisignature_transactions_should_wait_for_all_signatures() -> Result<()> {
let instructions = [mint_asset];
let transaction = client_2.build_transaction(instructions, UnlimitedMetadata::new())?;
let transaction = client_2
.get_original_transactions(&transaction, 3, Duration::from_millis(100))?
.last()
.expect("Found no pending transaction for this account.")
.clone();
.get_original_matching_transactions(&transaction, 3, Duration::from_millis(100))?
.pop()
.expect("Found no pending transaction for this account.");
client_2.submit_transaction(&client_2.sign_transaction(transaction)?)?;
thread::sleep(pipeline_time);
let assets = client_1
Expand Down
2 changes: 1 addition & 1 deletion client_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn submit(
let transactions = if context.skip_mst_check() {
vec![tx]
} else {
match iroha_client.get_original_transactions(
match iroha_client.get_original_matching_transactions(
&tx,
RETRY_COUNT_MST,
RETRY_IN_MST,
Expand Down
3 changes: 1 addition & 2 deletions torii/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ impl Torii {
))
.and(body::versioned()),
)
.or(endpoint4(
.or(endpoint3(
routing::handle_pending_transactions,
warp::path(uri::MATCHING_PENDING_TRANSACTIONS)
.and(add_state!(self.queue, self.sumeragi))
.and(routing::paginate())
.and(body::versioned()),
))
.or(endpoint3(
Expand Down
5 changes: 1 addition & 4 deletions torii/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use eyre::{eyre, WrapErr};
use futures::TryStreamExt;
use iroha_config::client_api::ConfigurationDTO;
use iroha_core::{
query::{pagination::Paginate, store::LiveQueryStoreHandle},
smartcontracts::query::ValidQueryRequest,
query::store::LiveQueryStoreHandle, smartcontracts::query::ValidQueryRequest,
sumeragi::SumeragiHandle,
};
use iroha_data_model::{
Expand Down Expand Up @@ -162,14 +161,12 @@ fn transaction_payload_eq_excluding_creation_time(
pub async fn handle_pending_transactions(
queue: Arc<Queue>,
sumeragi: SumeragiHandle,
pagination: Pagination,
transaction: SignedTransaction,
) -> Result<Scale<Vec<SignedTransaction>>> {
let query_response = sumeragi.apply_wsv(|wsv| {
queue
.all_transactions(wsv)
.map(Into::into)
.paginate(pagination)
.filter(|current_transaction: &SignedTransaction| {
transaction_payload_eq_excluding_creation_time(
current_transaction.payload(),
Expand Down

0 comments on commit 2a505ea

Please sign in to comment.