Skip to content

Commit 36692d3

Browse files
committed
Replace zero_rtt_accepted with zero_rtt_rejected
This is a breaking change.
1 parent 3b44051 commit 36692d3

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

irpc-iroh/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ impl irpc::rpc::RemoteConnection for IrohRemoteConnection {
6969
})
7070
}
7171

72-
fn zero_rtt_accepted(&self) -> BoxFuture<bool> {
73-
Box::pin(async { true })
72+
fn zero_rtt_rejected(&self) -> BoxFuture<bool> {
73+
Box::pin(async { false })
7474
}
7575
}
7676

@@ -99,13 +99,13 @@ impl irpc::rpc::RemoteConnection for IrohZrttRemoteConnection {
9999
})
100100
}
101101

102-
fn zero_rtt_accepted(&self) -> BoxFuture<bool> {
102+
fn zero_rtt_rejected(&self) -> BoxFuture<bool> {
103103
let conn = self.0.clone();
104104
Box::pin(async move {
105105
match conn.handshake_completed().await {
106-
Err(_) => false,
107-
Ok(ZeroRttStatus::Accepted(_)) => true,
108-
Ok(ZeroRttStatus::Rejected(_)) => false,
106+
Err(_) => true,
107+
Ok(ZeroRttStatus::Accepted(_)) => false,
108+
Ok(ZeroRttStatus::Rejected(_)) => true,
109109
}
110110
})
111111
}
@@ -165,8 +165,8 @@ impl RemoteConnection for IrohLazyRemoteConnection {
165165
})
166166
}
167167

168-
fn zero_rtt_accepted(&self) -> BoxFuture<bool> {
169-
Box::pin(async { true })
168+
fn zero_rtt_rejected(&self) -> BoxFuture<bool> {
169+
Box::pin(async { false })
170170
}
171171
}
172172

src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ impl<S: Service> Client<S> {
14841484
// see https://www.iroh.computer/blog/0rtt-api#connect-side
14851485
let buf = rpc::prepare_write::<S>(msg)?;
14861486
let (_tx, _rx) = request.write_raw(&buf).await?;
1487-
if !this.0.zero_rtt_accepted().await {
1487+
if this.0.zero_rtt_rejected().await {
14881488
// 0rtt was not accepted, the data is lost, send it again!
14891489
let Request::Remote(request) = this.request().await? else {
14901490
unreachable!()
@@ -1523,15 +1523,15 @@ impl<S: Service> Client<S> {
15231523
// see https://www.iroh.computer/blog/0rtt-api#connect-side
15241524
let buf = rpc::prepare_write::<S>(msg)?;
15251525
let (_tx, rx) = request.write_raw(&buf).await?;
1526-
if this.0.zero_rtt_accepted().await {
1527-
rx
1528-
} else {
1526+
if this.0.zero_rtt_rejected().await {
15291527
// 0rtt was not accepted, the data is lost, send it again!
15301528
let Request::Remote(request) = this.request().await? else {
15311529
unreachable!()
15321530
};
15331531
let (_tx, rx) = request.write_raw(&buf).await?;
15341532
rx
1533+
} else {
1534+
rx
15351535
}
15361536
.into()
15371537
}
@@ -1571,15 +1571,15 @@ impl<S: Service> Client<S> {
15711571
// see https://www.iroh.computer/blog/0rtt-api#connect-side
15721572
let buf = rpc::prepare_write::<S>(msg)?;
15731573
let (_tx, rx) = request.write_raw(&buf).await?;
1574-
if this.0.zero_rtt_accepted().await {
1575-
rx
1576-
} else {
1574+
if this.0.zero_rtt_rejected().await {
15771575
// 0rtt was not accepted, the data is lost, send it again!
15781576
let Request::Remote(request) = this.request().await? else {
15791577
unreachable!()
15801578
};
15811579
let (_tx, rx) = request.write_raw(&buf).await?;
15821580
rx
1581+
} else {
1582+
rx
15831583
}
15841584
.into()
15851585
}
@@ -1654,11 +1654,11 @@ impl<M> Clone for ClientInner<M> {
16541654

16551655
impl<M> ClientInner<M> {
16561656
#[allow(dead_code)]
1657-
async fn zero_rtt_accepted(&self) -> bool {
1657+
async fn zero_rtt_rejected(&self) -> bool {
16581658
match self {
1659-
ClientInner::Local(_sender) => true,
1659+
ClientInner::Local(_sender) => false,
16601660
#[cfg(feature = "rpc")]
1661-
ClientInner::Remote(remote_connection) => remote_connection.zero_rtt_accepted().await,
1661+
ClientInner::Remote(remote_connection) => remote_connection.zero_rtt_rejected().await,
16621662
#[cfg(not(feature = "rpc"))]
16631663
Self::Remote(_) => unreachable!(),
16641664
}
@@ -1892,10 +1892,10 @@ pub mod rpc {
18921892
&self,
18931893
) -> BoxFuture<std::result::Result<(quinn::SendStream, quinn::RecvStream), RequestError>>;
18941894

1895-
/// Returns whether 0-RTT data was accepted by the server.
1895+
/// Returns whether 0-RTT data was rejected by the server.
18961896
///
1897-
/// For connections that were fully authenticated before allowing to send any data, this should return `true`.
1898-
fn zero_rtt_accepted(&self) -> BoxFuture<bool>;
1897+
/// For connections that were fully authenticated before allowing to send any data, this should return `false`.
1898+
fn zero_rtt_rejected(&self) -> BoxFuture<bool>;
18991899
}
19001900

19011901
/// A connection to a remote service.
@@ -1928,8 +1928,8 @@ pub mod rpc {
19281928
})
19291929
}
19301930

1931-
fn zero_rtt_accepted(&self) -> BoxFuture<bool> {
1932-
Box::pin(async { true })
1931+
fn zero_rtt_rejected(&self) -> BoxFuture<bool> {
1932+
Box::pin(async { false })
19331933
}
19341934
}
19351935

@@ -1973,8 +1973,8 @@ pub mod rpc {
19731973
})
19741974
}
19751975

1976-
fn zero_rtt_accepted(&self) -> BoxFuture<bool> {
1977-
Box::pin(async { true })
1976+
fn zero_rtt_rejected(&self) -> BoxFuture<bool> {
1977+
Box::pin(async { false })
19781978
}
19791979
}
19801980

0 commit comments

Comments
 (0)