Skip to content

Commit

Permalink
Remove all deprecated except SQLiteDatabase
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
  • Loading branch information
yukibtc committed Sep 19, 2024
1 parent c30549b commit 4601678
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 376 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

### Removed

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

## [v0.35.0]
Expand Down
20 changes: 0 additions & 20 deletions crates/nostr-relay-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,26 +269,6 @@ impl RelayPool {
self.inner.save_subscription(id, filters).await
}

/// Send client message to all connected relays
#[deprecated(since = "0.35.0", note = "Use `send_msg_to` instead")]
pub async fn send_msg(
&self,
_msg: ClientMessage,
_opts: RelaySendOptions,
) -> Result<Output<()>, Error> {
Ok(Output::default())
}

/// Send multiple client messages at once to all connected relays
#[deprecated(since = "0.35.0", note = "Use `batch_msg_to` instead")]
pub async fn batch_msg(
&self,
_msgs: Vec<ClientMessage>,
_opts: RelaySendOptions,
) -> Result<Output<()>, Error> {
Ok(Output::default())
}

/// Send client message to specific relays
///
/// Note: **the relays must already be added!**
Expand Down
13 changes: 0 additions & 13 deletions crates/nostr-relay-pool/src/relay/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

//! Relay options

#[cfg(not(target_arch = "wasm32"))]
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering};
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -62,17 +60,6 @@ impl RelayOptions {
Self::default()
}

/// Set proxy
#[deprecated(since = "0.33.0", note = "Use `connection_mode` instead")]
#[cfg(not(target_arch = "wasm32"))]
pub fn proxy(mut self, proxy: Option<SocketAddr>) -> Self {
match proxy {
Some(proxy) => self.connection_mode = ConnectionMode::Proxy(proxy),
None => self.connection_mode = ConnectionMode::Direct,
};
self
}

/// Set connection mode
#[inline]
pub fn connection_mode(mut self, mode: ConnectionMode) -> Self {
Expand Down
9 changes: 3 additions & 6 deletions crates/nostr-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ async fn main() -> Result<()> {
client.add_relay("wss://relay.damus.io").await?;
client.add_relay("ws://jgqaglhautb4k6e6i2g34jakxiemqp6z4wynlirltuukgkft2xuglmqd.onion").await?;
// Add relay with custom options
client.add_relay_with_opts(
"wss://relay.nostr.info",
RelayOptions::new().write(false)
).await?;
// Add read relay
client.add_read_relay("wss://relay.nostr.info").await?;
// Connect to relays
client.connect().await;
Expand All @@ -77,7 +74,7 @@ async fn main() -> Result<()> {
client.publish_text_note("My first text note from rust-nostr!", []).await?;
// Create a POW text note
let event: Event = EventBuilder::text_note("POW text note from nostr-sdk", []).to_pow_event(&my_keys, 20)?;
let event: Event = EventBuilder::text_note("POW text note from nostr-sdk", []).pow(20).to_event(&my_keys)?;
client.send_event(event).await?; // Send to all relays
// client.send_event_to(["wss://relay.damus.io"], event).await?; // Send to specific relay
Expand Down
114 changes: 0 additions & 114 deletions crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,54 +277,6 @@ impl Client {
self.pool.filtering()
}

/// Mute [EventId]s
///
/// Add [EventId]s to blacklist
///
/// <div class="warning">Mute list event is not currently created/updated!</div>
#[deprecated(
since = "0.35.0",
note = "Check `RelayFiltering` instead. Use `client.filtering()` to get filtering list."
)]
pub async fn mute_ids<I>(&self, _ids: I)
where
I: IntoIterator<Item = EventId>,
{
}

/// Unmute [EventId]s
#[deprecated(
since = "0.35.0",
note = "Check `RelayFiltering` instead. Use `client.filtering()` to get filtering list."
)]
pub async fn unmute_ids<'a, I>(&self, _ids: I)
where
I: IntoIterator<Item = &'a EventId>,
{
}

/// Mute [PublicKey]s
#[deprecated(
since = "0.35.0",
note = "Check `RelayFiltering` instead. Use `client.filtering()` to get filtering list."
)]
pub async fn mute_public_keys<I>(&self, _public_keys: I)
where
I: IntoIterator<Item = PublicKey>,
{
}

/// Unmute [PublicKey]s
#[deprecated(
since = "0.35.0",
note = "Check `RelayFiltering` instead. Use `client.filtering()` to get filtering list."
)]
pub async fn unmute_public_keys<'a, I>(&self, _public_keys: I)
where
I: IntoIterator<Item = &'a PublicKey>,
{
}

/// Completely shutdown client
#[inline]
pub async fn shutdown(&self) -> Result<(), Error> {
Expand Down Expand Up @@ -562,30 +514,6 @@ impl Client {
.await
}

/// Add new relay with custom [`RelayOptions`]
#[deprecated(since = "0.35.0", note = "Use `RelayPool::add_relay` instead")]
pub async fn add_relay_with_opts<U>(&self, url: U, opts: RelayOptions) -> Result<bool, Error>
where
U: TryIntoUrl,
pool::Error: From<<U as TryIntoUrl>::Err>,
{
Ok(self.pool.add_relay(url, opts).await?)
}

/// Add multiple relays
#[deprecated(since = "0.35.0", note = "Use one of the add relay methods")]
pub async fn add_relays<I, U>(&self, relays: I) -> Result<(), Error>
where
I: IntoIterator<Item = U>,
U: TryIntoUrl,
pool::Error: From<<U as TryIntoUrl>::Err>,
{
for url in relays.into_iter() {
self.add_relay(url).await?;
}
Ok(())
}

/// Disconnect and remove relay
///
/// # Example
Expand Down Expand Up @@ -979,21 +907,6 @@ impl Client {
}
}

/// Get events of filters with [`FilterOptions`]
///
/// If timeout is set to `None`, the default from [`Options`] will be used.
#[inline]
#[deprecated(since = "0.34.0", note = "Use `client.pool().get_events_of(..)`.")]
pub async fn get_events_of_with_opts(
&self,
filters: Vec<Filter>,
timeout: Option<Duration>,
opts: FilterOptions,
) -> Result<Vec<Event>, Error> {
let timeout: Duration = timeout.unwrap_or(self.opts.timeout);
Ok(self.pool.get_events_of(filters, timeout, opts).await?)
}

/// Get events of filters from specific relays
#[inline]
pub async fn get_events_from<I, U>(
Expand Down Expand Up @@ -1077,25 +990,6 @@ impl Client {
.await?)
}

/// Send client message to **all relays**
#[deprecated(since = "0.35.0", note = "Use `send_msg_to` instead")]
pub async fn send_msg(&self, msg: ClientMessage) -> Result<Output<()>, Error> {
let opts: RelaySendOptions = self.opts.get_wait_for_send();
#[allow(deprecated)]
Ok(self.pool.send_msg(msg, opts).await?)
}

/// Batch send client messages to **all relays**
#[deprecated(since = "0.35.0", note = "Use `batch_msg_to` instead")]
pub async fn batch_msg(
&self,
msgs: Vec<ClientMessage>,
opts: RelaySendOptions,
) -> Result<Output<()>, Error> {
#[allow(deprecated)]
Ok(self.pool.batch_msg(msgs, opts).await?)
}

/// Send client message to a **specific relays**
#[inline]
pub async fn send_msg_to<I, U>(&self, urls: I, msg: ClientMessage) -> Result<Output<()>, Error>
Expand Down Expand Up @@ -1289,14 +1183,6 @@ impl Client {
}
}

/// Replaced by `fetch_metadata`
///
/// <https://github.com/nostr-protocol/nips/blob/master/01.md>
#[deprecated(since = "0.35.0", note = "Use `Client::fetch_metadata` instead.")]
pub async fn metadata(&self, public_key: PublicKey) -> Result<Metadata, Error> {
self.fetch_metadata(public_key, None).await
}

/// Update metadata
///
/// <https://github.com/nostr-protocol/nips/blob/master/01.md>
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() -> Result<()> {
let event: Event = EventBuilder::text_note("Hello from rust-nostr", []).to_event(&my_keys)?;
// New POW text note
let event: Event = EventBuilder::text_note("My first POW text note from rust-nostr", []).to_pow_event(&my_keys, 20)?;
let event: Event = EventBuilder::text_note("My first POW text note from rust-nostr", []).pow(20).to_event(&my_keys)?;
// Convert client nessage to JSON
let json = ClientMessage::event(event).as_json();
Expand Down
65 changes: 0 additions & 65 deletions crates/nostr/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,49 +305,6 @@ impl EventBuilder {
}
}

/// Build POW [`Event`]
#[deprecated(
since = "0.35.0",
note = "Use `EventBuilder::pow` to set a difficulty and then call `EventBuilder::to_event_with_ctx`."
)]
pub fn to_pow_event_with_ctx<C, R, T>(
self,
secp: &Secp256k1<C>,
rng: &mut R,
supplier: &T,
keys: &Keys,
difficulty: u8,
) -> Result<Event, Error>
where
C: Signing + Verification,
R: Rng + CryptoRng,
T: TimeSupplier,
{
let pubkey: PublicKey = keys.public_key();
#[allow(deprecated)]
Ok(self
.to_unsigned_pow_event_with_supplier(supplier, pubkey, difficulty)
.sign_with_ctx(secp, rng, keys)?)
}

/// Build unsigned POW [`Event`]
#[deprecated(
since = "0.35.0",
note = "Use `EventBuilder::pow` to set a difficulty and then call `EventBuilder::to_unsigned_event_with_supplier`."
)]
pub fn to_unsigned_pow_event_with_supplier<T>(
self,
supplier: &T,
pubkey: PublicKey,
difficulty: u8,
) -> UnsignedEvent
where
T: TimeSupplier,
{
self.pow(difficulty)
.to_unsigned_event_with_supplier(supplier, pubkey)
}

/// Build event
#[inline]
#[cfg(feature = "std")]
Expand All @@ -362,28 +319,6 @@ impl EventBuilder {
self.to_unsigned_event_with_supplier(&Instant::now(), pubkey)
}

/// Build POW [`Event`]
#[cfg(feature = "std")]
#[deprecated(
since = "0.35.0",
note = "Use `EventBuilder::pow` to set a difficulty and then call `EventBuilder::to_event`."
)]
pub fn to_pow_event(self, keys: &Keys, difficulty: u8) -> Result<Event, Error> {
#[allow(deprecated)]
self.to_pow_event_with_ctx(&SECP256K1, &mut OsRng, &Instant::now(), keys, difficulty)
}

/// Build unsigned POW [`Event`]
#[cfg(feature = "std")]
#[deprecated(
since = "0.35.0",
note = "Use `EventBuilder::pow` to set a difficulty and then call `EventBuilder::to_unsigned_event`."
)]
pub fn to_unsigned_pow_event(self, pubkey: PublicKey, difficulty: u8) -> UnsignedEvent {
#[allow(deprecated)]
self.to_unsigned_pow_event_with_supplier(&Instant::now(), pubkey, difficulty)
}

/// Profile metadata
///
/// <https://github.com/nostr-protocol/nips/blob/master/01.md>
Expand Down
6 changes: 0 additions & 6 deletions crates/nostr/src/event/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ impl EventId {
Self::from_byte_array(hash.to_byte_array())
}

/// Construct event ID
#[deprecated(since = "0.35.0", note = "Use `from_byte_array` instead")]
pub fn owned(bytes: [u8; Self::LEN]) -> Self {
Self::from_byte_array(bytes)
}

/// Construct event ID from 32-byte array
#[inline]
pub const fn from_byte_array(bytes: [u8; Self::LEN]) -> Self {
Expand Down
12 changes: 0 additions & 12 deletions crates/nostr/src/event/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,6 @@ impl Kind {
(*self).into()
}

/// Get as 32-bit unsigned integer
#[deprecated(since = "0.35.0")]
pub fn as_u32(&self) -> u32 {
self.as_u16() as u32
}

/// Get as 64-bit unsigned integer
#[deprecated(since = "0.35.0")]
pub fn as_u64(&self) -> u64 {
self.as_u16() as u64
}

/// Check if it's regular
///
/// Regular means that event is expected to be stored by relays.
Expand Down
Loading

0 comments on commit 4601678

Please sign in to comment.