Skip to content

Commit e938076

Browse files
committed
pool: add support to negentropy v1
Closes #253 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 1929f6b commit e938076

File tree

10 files changed

+403
-37
lines changed

10 files changed

+403
-37
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
* relay-builder: add `MockRelay` ([Yuki Kishimoto])
9797
* pool: add `RelayPool::disconnect_relay` method ([Yuki Kishimoto])
9898
* pool: add `RelayPool::relays_with_flag` and `RelayPool::all_relays` ([Yuki Kishimoto])
99+
* pool: add support to negentropy v1 ([Yuki Kishimoto])
99100
* sdk: add `Client::add_discovery_relay` ([Yuki Kishimoto])
100101
* sdk: add `Client::add_read_relay` and `Client::add_write_relay` ([Yuki Kishimoto])
101102
* sdk: add `Client::stream_events_targeted` ([Yuki Kishimoto])

Cargo.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ async-trait = "0.1"
2525
async-utility = "0.2"
2626
atomic-destructor = { version = "0.2", default-features = false }
2727
js-sys = "0.3"
28+
negentropy = { version = "0.4", default-features = false }
29+
negentropy-deprecated = { package = "negentropy", version = "0.3", default-features = false }
2830
nostr = { version = "0.34", path = "./crates/nostr", default-features = false }
2931
nostr-database = { version = "0.34", path = "./crates/nostr-database", default-features = false }
3032
nostr-indexeddb = { version = "0.34", path = "./crates/nostr-indexeddb", default-features = false }

bindings/nostr-ffi/src/message/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pub enum ClientMessageEnum {
3636
NegOpen {
3737
subscription_id: String,
3838
filter: Arc<Filter>,
39-
/// ID size (MUST be between 8 and 32, inclusive)
40-
id_size: u8,
39+
/// ID size (deprecated)
40+
id_size: Option<u8>,
4141
initial_message: String,
4242
},
4343
/// Negentropy Message

crates/nostr-relay-pool/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ nip11 = ["nostr/nip11"]
2020
async-utility.workspace = true
2121
async-wsocket = { version = "0.8", features = ["socks"] }
2222
atomic-destructor = { workspace = true, features = ["tracing"] }
23+
negentropy = { workspace = true, features = ["std"] }
24+
negentropy-deprecated = { workspace = true, features = ["std"] }
2325
nostr = { workspace = true, features = ["std"] }
2426
nostr-database.workspace = true
2527
thiserror.workspace = true

crates/nostr-relay-pool/src/relay/error.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::time::Duration;
88
use async_utility::thread;
99
use nostr::message::relay::NegentropyErrorCode;
1010
use nostr::message::MessageHandleError;
11-
use nostr::{event, negentropy, EventId, Kind, PublicKey};
11+
use nostr::{event, EventId, Kind, PublicKey};
1212
use nostr_database::DatabaseError;
1313
use thiserror::Error;
1414

@@ -27,6 +27,9 @@ pub enum Error {
2727
/// Negentropy error
2828
#[error(transparent)]
2929
Negentropy(#[from] negentropy::Error),
30+
/// Negentropy error
31+
#[error(transparent)]
32+
NegentropyDeprecated(#[from] negentropy_deprecated::Error),
3033
/// Database error
3134
#[error(transparent)]
3235
Database(#[from] DatabaseError),
@@ -90,8 +93,8 @@ pub enum Error {
9093
#[error("negentropy reconciliation error: {0}")]
9194
NegentropyReconciliation(NegentropyErrorCode),
9295
/// Negentropy not supported
93-
#[error("negentropy not supported")]
94-
NegentropyNotSupported,
96+
#[error("negentropy (maybe) not supported")]
97+
NegentropyMaybeNotSupported,
9598
/// Unknown negentropy error
9699
#[error("unknown negentropy error")]
97100
UnknownNegentropyError,

0 commit comments

Comments
 (0)