Skip to content

Commit

Permalink
add global constant for how many queues an OpSubmitter has
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Jan 15, 2025
1 parent 5255925 commit f2fc9f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion rust/main/agents/relayer/src/msg/op_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl OpQueue {
// The other consideration is whether to put the channel receiver in the OpQueue or in a dedicated task
// that also holds an Arc to the Mutex. For simplicity, we'll put it in the OpQueue for now.
let mut message_retry_requests = vec![];
// we only need to lock self.retry_receiver once
{
let mut retry_receiver = self.retry_receiver.lock().await;
while let Ok(retry_request) = retry_receiver.try_recv() {
Expand Down
2 changes: 2 additions & 0 deletions rust/main/agents/relayer/src/msg/op_submitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ use crate::server::MessageRetryRequest;
use super::op_queue::OpQueue;
use super::op_queue::OperationPriorityQueue;

pub const SUBMITTER_QUEUE_COUNT: usize = 3;

/// SerialSubmitter accepts operations over a channel. It is responsible for
/// executing the right strategy to deliver those messages to the destination
/// chain. It is designed to be used in a scenario allowing only one
Expand Down
5 changes: 3 additions & 2 deletions rust/main/agents/relayer/src/server/message_retry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use crate::settings::matching_list::MatchingList;
use crate::{msg::op_submitter::SUBMITTER_QUEUE_COUNT, settings::matching_list::MatchingList};
use axum::{extract::State, routing, Json, Router};
use derive_new::new;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -52,7 +52,8 @@ async fn retry_message(
// Create a channel that can hold each chain's SerialSubmitter
// message retry responses.
// 3 queues for each chain (prepare, submit, confirm)
let (transmitter, mut receiver) = mpsc::channel(3 * state.destination_chains);
let (transmitter, mut receiver) =
mpsc::channel(SUBMITTER_QUEUE_COUNT * state.destination_chains);
state
.retry_request_transmitter
.send(Arc::new(MessageRetryRequest {
Expand Down

0 comments on commit f2fc9f1

Please sign in to comment.