Skip to content

Commit

Permalink
oh
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 20, 2024
1 parent 92a276d commit fa31f65
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
38 changes: 27 additions & 11 deletions mantis/node/src/bin/mantis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,11 @@ async fn solve_orders(solver_args: &SolverArgs) {
chain_id: args.main_chain_id.clone(),
};
loop {
let tip =
let mut tip =
get_latest_block_and_account_by_key(&args.rpc_centauri, &args.grpc_centauri, &signer)
.await;
let stale_orders = mantis_node::mantis::indexer::get_stale_orders(
&args.order_contract,
&mut wasm_read_client,
&tip,
)
.await;
if stale_orders.len() > 0 || rand::random::<u8>() > 200 {
if stale_orders.len() > 0 {
log::warn!(target: "mantis::autopilot", "timedouted orders");
}

if rand::random::<u8>() > 150 {
autopilot::cleanup(
&mut write_client,
&mut cosmos_query_client,
Expand All @@ -99,6 +91,30 @@ async fn solve_orders(solver_args: &SolverArgs) {
gas,
)
.await;
tip.account.sequence += 1;
} else {
let stale_orders = mantis_node::mantis::indexer::get_stale_orders(
&args.order_contract,
&mut wasm_read_client,
&tip,
)
.await;
if stale_orders.len() > 0 {
if stale_orders.len() > 0 {
log::warn!(target: "mantis::autopilot", "timedouted orders");
}
autopilot::cleanup(
&mut write_client,
&mut cosmos_query_client,
args.order_contract.clone(),
&signer,
&cosmos_chain_info,
&tip,
gas,
)
.await;
tip.account.sequence += 1;
}
}

let mut tip =
Expand Down
2 changes: 1 addition & 1 deletion mantis/node/src/mantis/cosmos/cosmwasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub async fn smart_query<T: serde::ser::Serialize, O: serde::de::DeserializeOwne
let result = read
.smart_contract_state(orders_request)
.await
.expect("why cannot execute?")
.expect("smart_query failed")
.into_inner()
.data;
serde_json_wasm::from_slice(&result).expect("result parsed")
Expand Down

0 comments on commit fa31f65

Please sign in to comment.