Skip to content

Commit fd315d7

Browse files
authored
chore(rust): Bump rust-ipfs to latest main and adapt to the breaking changes (#619)
* Bump and stub incompatible functions * Update `pubsub_subscribe` * Update `IpfsBuilder` * Update `pubsub_unsubscribe()` * Update `pubsub_publish()` * Wire the pubsub events * Remove references to no longer available transport configuration * Fix comment * Clean up deprecated and unused * Update dictionary * Update tests * Fix lints * Fix formatting
1 parent 48faa69 commit fd315d7

File tree

7 files changed

+88
-115
lines changed

7 files changed

+88
-115
lines changed

.config/dictionaries/project.dic

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ asyncio
1212
Attributes
1313
auditability
1414
Auliffe
15+
autonat
1516
auxdata
1617
babystep
1718
backpressure
1819
bech
20+
Behaviour
1921
bimap
2022
bindgen
2123
bkioshn
@@ -48,6 +50,7 @@ ciphertexts
4850
Coap
4951
codegen
5052
codepoints
53+
connexa
5154
coti
5255
coverallsapp
5356
cpus
@@ -62,6 +65,7 @@ Datelike
6265
DBSTATUS
6366
dbsync
6467
dcbor
68+
dcutr
6569
decompressor
6670
delegators
6771
devnet
@@ -141,6 +145,7 @@ jormungandr
141145
Jörmungandr
142146
jsonschema
143147
Justfile
148+
keypair
144149
kiduri
145150
labelloc
146151
lcov
@@ -245,6 +250,7 @@ pytype
245250
qpsg
246251
qrcode
247252
quic
253+
rafal
248254
rankdir
249255
rapidoc
250256
readlinkat

rust/c509-certificate/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ hex = "0.4.3"
2323
oid = "0.2.1"
2424
oid-registry = "0.7.1"
2525
asn1-rs = "0.6.2"
26-
anyhow = "1.0.95"
26+
anyhow = "1.0.99"
2727
bimap = "0.6.3"
2828
strum = "0.26.3"
2929
strum_macros = "0.26.4"

rust/hermes-ipfs/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ repository.workspace = true
1313
workspace = true
1414

1515
[dependencies]
16-
anyhow = "1.0.95"
16+
anyhow = "1.0.100"
1717
derive_more = {version = "2.0.1", features = ["from","into","display"] }
1818
ipld-core = { version = "0.4.1", features = ["serde"]}
1919
# A fork of crates-io version with updated dependencies (`libp2p` and `ring` in particular).
2020
# rev-26b99cb as at July 30, 2025
21-
rust-ipfs = { version = "0.15.0", git = "https://github.com/dariusc93/rust-ipfs", rev = "26b99cb" }
21+
rust-ipfs = { version = "0.15.0", git = "https://github.com/dariusc93/rust-ipfs", rev = "0a6269e05a4ccfaa547a47a56f92171e4abc0564" }
2222
tokio = "1.46.0"
23+
futures = "0.3.31"
24+
libp2p = "0.56.0"
25+
connexa = { version = "0.4.1", features = ["identify", "dcutr", "gossipsub", "autonat", "relay", "kad", "keypair_base64_encoding", "ping", "request-response", "request-response-misc", "rendezvous", "mdns"] }
2326

2427
[dev-dependencies]
2528
# Dependencies used by examples

rust/hermes-ipfs/examples/hermes-ipfs-cli.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Hermes IPFS VFS compatibility
22
33
use clap::{Parser, Subcommand};
4-
use hermes_ipfs::{HermesIpfs, IpfsBuilder};
4+
use connexa::dummy;
5+
use hermes_ipfs::{HermesIpfs, HermesIpfsBuilder};
56
use lipsum::lipsum;
67
use rust_ipfs::IpfsPath;
78

@@ -44,11 +45,11 @@ async fn main() -> anyhow::Result<()> {
4445
let args = Cli::parse();
4546
let base_dir = dirs::data_dir().unwrap_or_else(|| std::path::PathBuf::from("."));
4647
let ipfs_data_path = base_dir.as_path().join("hermes/ipfs");
47-
let builder = IpfsBuilder::new()
48+
let builder = HermesIpfsBuilder::<dummy::Behaviour>::new()
4849
.with_default()
4950
.set_default_listener()
5051
// TODO(saibatizoku): Re-Enable default transport config when libp2p Cert bug is fixed
51-
.disable_tls()
52+
//.enable_secure_websocket()
5253
.set_disk_storage(ipfs_data_path);
5354
let hermes_node: HermesIpfs = builder.start().await?.into();
5455
match args.command {

rust/hermes-ipfs/examples/pubsub.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//! * The task that reads lines from stdin and publishes them as either node.
1515
use std::io::Write;
1616

17-
use hermes_ipfs::{FutureExt, HermesIpfs, StreamExt, pin_mut};
18-
use rust_ipfs::PubsubEvent;
17+
use futures::{FutureExt, StreamExt, pin_mut};
18+
use hermes_ipfs::HermesIpfs;
1919
use rustyline_async::Readline;
2020

2121
#[allow(clippy::indexing_slicing)]
@@ -57,15 +57,11 @@ async fn start_bootstrapped_nodes() -> anyhow::Result<(HermesIpfs, HermesIpfs)>
5757
/// Main function
5858
async fn main() -> anyhow::Result<()> {
5959
let topic = String::from("ipfs-chat");
60-
let option_topic = Option::Some(topic.clone());
6160

6261
// Initialize the repo and start a daemon
6362
let (hermes_a, hermes_b) = start_bootstrapped_nodes().await?;
6463
let (mut rl, mut stdout) = Readline::new(format!("{} > ", "Write message to publish"))?;
6564

66-
let mut event_stream = hermes_a.pubsub_events(option_topic.clone()).await?;
67-
let mut event_stream_b = hermes_b.pubsub_events(option_topic).await?;
68-
6965
let stream = hermes_a.pubsub_subscribe(topic.clone()).await?;
7066
let stream_b = hermes_b.pubsub_subscribe(topic.clone()).await?;
7167

@@ -79,24 +75,12 @@ async fn main() -> anyhow::Result<()> {
7975
tokio::select! {
8076
data = stream.next() => {
8177
if let Some(msg) = data {
82-
writeln!(stdout, "NODE A RECV: {}", String::from_utf8_lossy(&msg.data))?;
78+
writeln!(stdout, "NODE A RECV: {:?}", &msg)?;
8379
}
8480
}
8581
data = stream_b.next() => {
8682
if let Some(msg) = data {
87-
writeln!(stdout, "NODE B RECV: {}", String::from_utf8_lossy(&msg.data))?;
88-
}
89-
}
90-
Some(event) = event_stream.next() => {
91-
match event {
92-
PubsubEvent::Subscribe { peer_id, topic } => writeln!(stdout, "{peer_id} subscribed to {topic:?}")?,
93-
PubsubEvent::Unsubscribe { peer_id, topic } => writeln!(stdout, "{peer_id} unsubscribed from {topic:?}")?,
94-
}
95-
}
96-
Some(event) = event_stream_b.next() => {
97-
match event {
98-
PubsubEvent::Subscribe { peer_id , topic} => writeln!(stdout, "{peer_id} subscribed to {topic:?}")?,
99-
PubsubEvent::Unsubscribe { peer_id, topic } => writeln!(stdout, "{peer_id} unsubscribed from {topic:?}")?,
83+
writeln!(stdout, "NODE B RECV: {:?}", &msg)?;
10084
}
10185
}
10286
line = rl.readline().fuse() => match line {

rust/hermes-ipfs/examples/put-get-dht.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ async fn main() -> anyhow::Result<()> {
4848
println!("* Hermes IPFS node A is publishing 'my_key' to DHT.");
4949
hermes_ipfs_a.dht_put(b"my_key", ipfs_file).await?;
5050
println!("* Hermes IPFS node B is getting 'my_key' from DHT.");
51-
let data_retrieved = hermes_ipfs_b.dht_get(b"my_key").await?;
51+
let key: Vec<u8> = "my_key".bytes().collect();
52+
let data_retrieved = hermes_ipfs_b.dht_get(key).await?;
5253
let data = String::from_utf8(data_retrieved)?;
5354
println!(" Got data: {data:?}");
5455
// Stop the nodes and exit.

0 commit comments

Comments
 (0)