Skip to content

Commit 26a501c

Browse files
committed
Simplified SendInfo and RecvInfo to only contain phase
1 parent e227be1 commit 26a501c

File tree

3 files changed

+5
-64
lines changed

3 files changed

+5
-64
lines changed

examples/api-integration/src/main.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,13 @@ impl Channel for HttpChannel {
379379
let client = reqwest::Client::new();
380380
let url = format!("{}msg/{}", self.urls[p], self.party);
381381
let mb = msg.len() as f64 / 1024.0 / 1024.0;
382-
let i = info.sent();
383-
let total = info.total();
384382
let phase = info.phase();
385-
if i == 1 {
386-
info!("Sending msg {phase} to party {p} ({mb:.2}MB), {i}/{total}...");
387-
} else {
388-
info!(" (sending msg {phase} to party {p} ({mb:.2}MB), {i}/{total})");
389-
}
383+
info!("Sending msg {phase} to party {p} ({mb:.2}MB)...");
390384
loop {
391385
sleep(Duration::from_millis(simulated_delay_in_ms)).await;
392386
let req = client.post(&url).body(msg.clone()).send();
393387
let Ok(Ok(res)) = timeout(Duration::from_secs(1), req).await else {
394-
warn!(" req timeout: chunk {}/{} for party {}", i + 1, total, p);
388+
warn!(" req timeout: party {}", p);
395389
continue;
396390
};
397391
match res.status() {

examples/sql-integration/src/main.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -695,19 +695,13 @@ impl Channel for HttpChannel {
695695
let client = reqwest::Client::new();
696696
let url = format!("{}msg/{}", self.urls[p], self.party);
697697
let mb = msg.len() as f64 / 1024.0 / 1024.0;
698-
let i = info.sent();
699-
let total = info.total();
700698
let phase = info.phase();
701-
if i == 1 {
702-
info!("Sending msg {phase} to party {p} ({mb:.2}MB), {i}/{total}...");
703-
} else {
704-
info!(" (sending msg {phase} to party {p} ({mb:.2}MB), {i}/{total})");
705-
}
699+
info!("Sending msg {phase} to party {p} ({mb:.2}MB)...");
706700
loop {
707701
sleep(Duration::from_millis(simulated_delay_in_ms)).await;
708702
let req = client.post(&url).body(msg.clone()).send();
709703
let Ok(Ok(res)) = timeout(Duration::from_secs(1), req).await else {
710-
warn!(" req timeout: chunk {}/{} for party {}", i + 1, total, p);
704+
warn!(" req timeout: party {}", p);
711705
continue;
712706
};
713707
match res.status() {

src/channel.rs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -61,64 +61,26 @@ pub enum ErrorKind {
6161
#[derive(Debug, Clone)]
6262
pub struct SendInfo {
6363
phase: String,
64-
current_msg: usize,
65-
remaining_msgs: usize,
6664
}
6765

6866
impl SendInfo {
6967
/// The name of the protocol phase that sent the message.
7068
pub fn phase(&self) -> &str {
7169
&self.phase
7270
}
73-
74-
/// How many chunks have already been sent, 1 for the first message, 2 for the second, etc.
75-
pub fn sent(&self) -> usize {
76-
self.current_msg + 1
77-
}
78-
79-
/// How many chunks have yet to be sent for the full message to be transmitted.
80-
pub fn remaining(&self) -> usize {
81-
self.remaining_msgs
82-
}
83-
84-
/// The total number of chunks that make up the full message.
85-
pub fn total(&self) -> usize {
86-
self.sent() + self.remaining()
87-
}
8871
}
8972

9073
/// Information about a received message that can be useful for logging.
9174
#[derive(Debug, Clone)]
9275
pub struct RecvInfo {
9376
phase: String,
94-
current_msg: usize,
95-
remaining_msgs: Option<usize>,
9677
}
9778

9879
impl RecvInfo {
9980
/// The name of the protocol phase that sent the message.
10081
pub fn phase(&self) -> &str {
10182
&self.phase
10283
}
103-
104-
/// How many chunks have already been sent, 1 for the first message, 2 for the second, etc.
105-
pub fn sent(&self) -> usize {
106-
self.current_msg + 1
107-
}
108-
109-
/// How many chunks have yet to be sent for the full message to be transmitted.
110-
///
111-
/// Will be `None` for the first message, before it is clear how many chunks need to be sent.
112-
pub fn remaining(&self) -> Option<usize> {
113-
self.remaining_msgs
114-
}
115-
116-
/// The total number of chunks that make up the full message.
117-
///
118-
/// Will be `None` for the first message, before it is clear how many chunks need to be sent.
119-
pub fn total(&self) -> Option<usize> {
120-
self.remaining().map(|remaining| self.sent() + remaining)
121-
}
12284
}
12385

12486
/// A communication channel used to send/receive messages to/from another party.
@@ -166,8 +128,6 @@ pub(crate) async fn send_to<S: Serialize + std::fmt::Debug>(
166128
})?;
167129
let info = SendInfo {
168130
phase: phase.to_string(),
169-
current_msg: 0,
170-
remaining_msgs: 0,
171131
};
172132
channel
173133
.send_bytes_to(party, data, info)
@@ -187,8 +147,6 @@ pub(crate) async fn recv_from<T: DeserializeOwned + std::fmt::Debug>(
187147
) -> Result<Vec<T>, Error> {
188148
let info = RecvInfo {
189149
phase: phase.to_string(),
190-
current_msg: 0,
191-
remaining_msgs: Some(0),
192150
};
193151
let data = channel
194152
.recv_bytes_from(party, info)
@@ -417,12 +375,7 @@ impl Channel for SimpleChannel {
417375
self.bytes_sent
418376
.fetch_add(msg.len() as u64, Ordering::Relaxed);
419377
let mb = msg.len() as f64 / 1024.0 / 1024.0;
420-
let i = info.sent();
421-
if i == 1 {
422-
trace!(size = mb, "Sending msg");
423-
} else {
424-
trace!(size = mb, " (continued sending msg)");
425-
}
378+
trace!(size = mb, "Sending msg");
426379
self.s[p]
427380
.as_ref()
428381
.unwrap_or_else(|| panic!("No sender for party {p}"))

0 commit comments

Comments
 (0)