Skip to content

Commit

Permalink
pool: remove RelayPool::reconcile_with_items
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
  • Loading branch information
yukibtc committed Oct 14, 2024
1 parent f2cdd2d commit b934aa0
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 73 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@

* Remove deprecated ([Yuki Kishimoto])
* pool: remove `RelayPool::reconcile_advanced` ([Yuki Kishimoto])
* pool: remove `RelayPool::reconcile_with_items` ([Yuki Kishimoto])
* webln: remove `nostr-webln` crate ([Yuki Kishimoto])

## [v0.35.0]
Expand Down
19 changes: 0 additions & 19 deletions bindings/nostr-sdk-ffi/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub mod result;
use self::result::{Output, SendEventOutput, SubscribeOutput};
use crate::database::events::Events;
use crate::error::Result;
use crate::negentropy::NegentropyItem;
use crate::pool::result::ReconciliationOutput;
use crate::relay::options::{FilterOptions, NegentropyOptions};
use crate::relay::{RelayFiltering, RelayOptions, RelaySendOptions, SubscribeOptions};
Expand Down Expand Up @@ -392,24 +391,6 @@ impl RelayPool {
.into())
}

/// Negentropy reconciliation with custom items
pub async fn reconcile_with_items(
&self,
filter: &Filter,
items: Vec<NegentropyItem>,
opts: &NegentropyOptions,
) -> Result<ReconciliationOutput> {
let items = items
.into_iter()
.map(|item| (**item.id, **item.timestamp))
.collect();
Ok(self
.inner
.reconcile_with_items(filter.deref().clone(), items, **opts)
.await?
.into())
}

/// Handle relay pool notifications
pub async fn handle_notifications(&self, handler: Arc<dyn HandleNotification>) -> Result<()> {
Ok(self
Expand Down
17 changes: 0 additions & 17 deletions bindings/nostr-sdk-js/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,23 +430,6 @@ impl JsRelayPool {
.map(|o| o.into())
}

// /// Negentropy reconciliation with custom items
// pub async fn reconcile_with_items(
// &self,
// filter: &JsFilter,
// items: Vec<NegentropyItem>,
// opts: &JsNegentropyOptions,
// ) -> Result<()> {
// let items = items
// .into_iter()
// .map(|item| (**item.id, **item.timestamp))
// .collect();
// Ok(self
// .inner
// .reconcile_with_items(filter.deref().clone(), items, **opts)
// .await?)
// }

// /// Handle relay pool notifications
// pub async fn handle_notifications(
// &self,
Expand Down
12 changes: 0 additions & 12 deletions crates/nostr-relay-pool/src/pool/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,18 +962,6 @@ impl InternalRelayPool {
self.reconcile_targeted(targets, opts).await
}

#[inline]
pub async fn reconcile_with_items(
&self,
filter: Filter,
items: Vec<(EventId, Timestamp)>,
opts: NegentropyOptions,
) -> Result<Output<Reconciliation>, Error> {
let urls: Vec<Url> = self.relay_urls().await;
let targets = urls.into_iter().map(|u| (u, filter.clone(), items.clone()));
self.reconcile_targeted(targets, opts).await
}

pub async fn reconcile_targeted<I, U>(
&self,
targets: I,
Expand Down
11 changes: 0 additions & 11 deletions crates/nostr-relay-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,17 +630,6 @@ impl RelayPool {
self.inner.reconcile_with(urls, filter, opts).await
}

/// Negentropy reconciliation with all relays and custom items
#[inline]
pub async fn reconcile_with_items(
&self,
filter: Filter,
items: Vec<(EventId, Timestamp)>,
opts: NegentropyOptions,
) -> Result<Output<Reconciliation>, Error> {
self.inner.reconcile_with_items(filter, items, opts).await
}

/// Targeted negentropy reconciliation
///
/// Reconcile events with specific relays and filters
Expand Down
1 change: 1 addition & 0 deletions crates/nostr-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ required-features = ["all-nips", "lmdb"]

[[example]]
name = "negentropy"
required-features = ["all-nips", "lmdb"]

[[example]]
name = "nip47"
Expand Down
7 changes: 4 additions & 3 deletions crates/nostr-sdk/examples/negentropy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ async fn main() -> Result<()> {
let public_key =
PublicKey::from_bech32("npub1080l37pfvdpyuzasyuy2ytjykjvq3ylr5jlqlg7tvzjrh9r8vn3sf5yaph")?;

let client = Client::default();
let database = NostrLMDB::open("./db/nostr-lmdb")?;
let client: Client = ClientBuilder::default().database(database).build();

client.add_relay("wss://atl.purplerelay.com").await?;
client.add_relay("wss://nostr.wine").await?;
client.add_relay("wss://relay.damus.io").await?;
client.add_relay("wss://nostr.oxtr.dev").await?;

client.connect().await;

let my_items = Vec::new();
let filter = Filter::new().author(public_key).limit(10);
let opts = NegentropyOptions::default();
let output = client.reconcile_with_items(filter, my_items, opts).await?;
let output = client.reconcile(filter, opts).await?;
println!("Success: {:?}", output.success);
println!("Failed: {:?}", output.failed);

Expand Down
11 changes: 0 additions & 11 deletions crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,17 +1739,6 @@ impl Client {
Ok(self.pool.reconcile_with(urls, filter, opts).await?)
}

/// Negentropy reconciliation with all relays and custom items
#[inline]
pub async fn reconcile_with_items(
&self,
filter: Filter,
items: Vec<(EventId, Timestamp)>,
opts: NegentropyOptions,
) -> Result<Output<Reconciliation>, Error> {
Ok(self.pool.reconcile_with_items(filter, items, opts).await?)
}

/// Targeted negentropy reconciliation
///
/// Reconcile events with specific relays and filters
Expand Down

0 comments on commit b934aa0

Please sign in to comment.