Skip to content

Commit f24e27d

Browse files
committed
- fix custom protocol example
- remove Handler helper struct in rpc - add iroh to allowed git deps
1 parent 6b094d3 commit f24e27d

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

deny.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ ignore = [
3838

3939
[sources]
4040
allow-git = [
41-
# "https://github.com/n0-computer/iroh.git",
41+
"https://github.com/n0-computer/iroh.git",
4242
]

examples/custom-protocol.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ impl ProtocolHandler for BlobSearch {
144144
///
145145
/// The returned future runs on a newly spawned tokio task, so it can run as long as
146146
/// the connection lasts.
147-
fn accept(self: Arc<Self>, connecting: Connecting) -> BoxedFuture<Result<()>> {
147+
fn accept(&self, connecting: Connecting) -> BoxedFuture<Result<()>> {
148+
let this = self.clone();
148149
// We have to return a boxed future from the handler.
149150
Box::pin(async move {
150151
// Wait for the connection to be fully established.
@@ -162,7 +163,7 @@ impl ProtocolHandler for BlobSearch {
162163

163164
// Now, we can perform the actual query on our local database.
164165
let query = String::from_utf8(query_bytes)?;
165-
let hashes = self.query_local(&query);
166+
let hashes = this.query_local(&query);
166167

167168
// We want to return a list of hashes. We do the simplest thing possible, and just send
168169
// one hash after the other. Because the hashes have a fixed size of 32 bytes, this is

src/rpc.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use std::{
44
io,
5-
ops::Deref,
65
sync::{Arc, Mutex},
76
};
87

@@ -82,29 +81,12 @@ impl<D: crate::store::Store> Blobs<D> {
8281
C: ChannelTypes<RpcService>,
8382
{
8483
use Request::*;
85-
let handler = Handler(self);
84+
let handler = self;
8685
match msg {
8786
Blobs(msg) => handler.handle_blobs_request(msg, chan).await,
8887
Tags(msg) => handler.handle_tags_request(msg, chan).await,
8988
}
9089
}
91-
}
92-
93-
#[derive(Clone)]
94-
struct Handler<S>(Blobs<S>);
95-
96-
impl<S> Deref for Handler<S> {
97-
type Target = Blobs<S>;
98-
99-
fn deref(&self) -> &Self::Target {
100-
&self.0
101-
}
102-
}
103-
104-
impl<D: crate::store::Store> Handler<D> {
105-
fn store(&self) -> &D {
106-
&self.0.store
107-
}
10890

10991
/// Handle a tags request
11092
pub async fn handle_tags_request<C>(

0 commit comments

Comments
 (0)