Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gossip #176

Merged
merged 27 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e7db3f1
pool: add `INBOX`, `OUTBOX` and `DISCOVERY` flags
yukibtc Apr 5, 2024
116c99b
pool: add `RelayPool::relays_with_flag`
yukibtc Apr 6, 2024
ed2685a
database: add `NostrDatabaseExt::relay_list`
yukibtc Apr 9, 2024
e78f50e
pool: add `AtomicRelayServiceFlags::can_read` and `AtomicRelayService…
yukibtc Apr 10, 2024
69a2e1d
pool: improve relay service flags and add `RelayPool::all_relays`
yukibtc Apr 10, 2024
784700b
sdk: add `Client::add_discovery_relay`
yukibtc Aug 12, 2024
76d8c9f
sdk: add `Options::gossip`
yukibtc Sep 3, 2024
1694fbd
sdk: initial `gossip` support for `Client::send_event`
yukibtc Sep 3, 2024
0e083bc
sdk: add `Client::add_read_relay` and `Client::add_write_relay`
yukibtc Sep 3, 2024
30a3c13
sdk: deprecate `Client::add_relay_with_opts` and `Client::add_relays`
yukibtc Sep 3, 2024
7c0d1e7
sdk: deprecate `RelayPool::send_msg` and `RelayPool::batch_msg`
yukibtc Sep 3, 2024
e4a3e41
pool: `RelayPool::send_event` and `RelayPool::batch_event` send only …
yukibtc Sep 3, 2024
cdcce2a
pool: `RelayPool::subscribe_with_id`, `RelayPool::get_events_of` and …
yukibtc Sep 3, 2024
fad3bd6
sdk: improve `GossipGraph` and `Client::send_event` method
yukibtc Sep 3, 2024
084060a
nostr: add `nip65::extract_owned_relay_list`
yukibtc Sep 4, 2024
2f40540
database: add `NostrDatabaseExt::relay_lists`
yukibtc Sep 4, 2024
520e96c
nostr: use `BTree` in `Filter` struct
yukibtc Sep 8, 2024
99310fd
nostr: add `Filter::extract_public_keys` method
yukibtc Sep 9, 2024
c750f4c
sdk: add `Client::stream_events_targeted`
yukibtc Sep 9, 2024
fb71d62
sdk: add gossip support to `Client::get_events_of` and `Client::strea…
yukibtc Sep 9, 2024
5253653
sdk: add `Client::subscribe_targeted`
yukibtc Sep 9, 2024
4b8f50d
sdk: add gossip support to `Client::subscribe` and `Client::subscribe…
yukibtc Sep 9, 2024
c9f369b
Update CHANGELOG
yukibtc Sep 9, 2024
460d1bc
sdk: improve `Client::relays` doc
yukibtc Sep 9, 2024
d18a83f
sdk: improve `GossipGraph::break_down_filters` method
yukibtc Sep 9, 2024
fb174b8
pool: use `READ` and `WRITE` relays for reconciliation
yukibtc Sep 9, 2024
c2232c0
sdk: get relay list events also from database in `Client::update_outd…
yukibtc Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@
* pool: deprecate auto adjustment of retry seconds for relays ([Yuki Kishimoto])
* pool: avoid unnecessary `Url` and `Relay` clone in `RelayPool` methods ([Yuki Kishimoto])
* pool: avoid `Relay` clone in `RelayPool::connect_relay` method ([Yuki Kishimoto])
* pool: `RelayPool::send_event` and `RelayPool::batch_event` send only to relays with `WRITE` flag ([Yuki Kishimoto])
* pool: `RelayPool::subscribe_with_id`, `RelayPool::get_events_of` and `RelayPool::stream_events_of` REQ events only to relays with `READ` flag ([Yuki Kishimoto])
* signer: update NIP-04 and NIP-44 methods signature ([Yuki Kishimoto])
* webln: bump `webln` to `v0.3` ([Yuki Kishimoto])
* sqlite: deprecate `SQLiteDatabase` in favor of LMDB ([Yuki Kishimoto])
* sdk: bump `lnurl-pay` to `v0.6` ([Yuki Kishimoto])
* sdk: update `Client::gift_wrap` and `Client::gift_wrap_to` methods signature ([Yuki Kishimoto])
* sdk: document and rename `Client::metadata` to `Client::fetch_metadata` ([Janek])
* sdk: update `Client::shutdown` method fingerprint ([Yuki Kishimoto])
* sdk: deprecate `Client::add_relay_with_opts` and `Client::add_relays` ([Yuki Kishimoto])
* sdk: deprecate `RelayPool::send_msg` and `RelayPool::batch_msg` ([Yuki Kishimoto])
* ffi(nostr): impl `Display` for `Coordinate` ([Yuki Kishimoto])
* ffi(sdk): change `Connection::embedded_tor` fingerprint for `android` and `ios` targets ([Yuki Kishimoto])

Expand All @@ -82,11 +86,21 @@
* nostr: add `Timestamp::from_secs` ([Yuki Kishimoto])
* nostr: add `EventId::from_byte_array` ([Yuki Kishimoto])
* nostr: add `Timestamp::min` and `Timestamp::max` ([Yuki Kishimoto])
* nostr: add `nip65::extract_owned_relay_list` ([Yuki Kishimoto])
* database: add `DatabaseHelper::fast_query` ([Yuki Kishimoto])
* database: add `NostrDatabase::check_id` ([Yuki Kishimoto])
* database: add `NostrDatabaseExt::relay_lists` ([Yuki Kishimoto])
* lmdb: add LMDB storage backend ([Yuki Kishimoto])
* relay-builder: add `MockRelay` ([Yuki Kishimoto])
* pool: add `RelayPool::disconnect_relay` method ([Yuki Kishimoto])
* pool: add `RelayPool::relays_with_flag` and `RelayPool::all_relays` ([Yuki Kishimoto])
* sdk: add `Client::add_discovery_relay` ([Yuki Kishimoto])
* sdk: add `Client::add_read_relay` and `Client::add_write_relay` ([Yuki Kishimoto])
* sdk: add `Client::stream_events_targeted` ([Yuki Kishimoto])
* sdk: add `Client::subscribe_targeted` ([Yuki Kishimoto])
* sdk: add gossip support to `Client::send_event` ([Yuki Kishimoto])
* sdk: add gossip support to `Client::get_events_of` and `Client::stream_events_of` ([Yuki Kishimoto])
* sdk: add gossip support to `Client::subscribe` and `Client::subscribe_with_id` ([Yuki Kishimoto])
* bindings(nostr): expose `as_pretty_json` for some structs ([Yuki Kishimoto])
* bindings(sdk): expose `Client::fetch_metadata` ([Yuki Kishimoto])
* bindings(sdk): expose `Client::pool` method ([Yuki Kishimoto])
Expand All @@ -95,6 +109,7 @@
* js(nostr): add `Kind` object ([Yuki Kishimoto])
* js(nostr): expose `getNip05Profile` function ([Yuki Kishimoto])
* js(nostr): expose missing methods to `JsCoordinate` ([Yuki Kishimoto])
* js(sdk): expose `RelayPool::relays` ([Yuki Kishimoto])
* book: add some python examples ([RydalWater])

### Fixed
Expand Down
36 changes: 19 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/nostr-ffi/src/nips/nip65.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ impl From<nip65::RelayMetadata> for RelayMetadata {
#[uniffi::export]
pub fn extract_relay_list(event: &Event) -> HashMap<String, Option<RelayMetadata>> {
nip65::extract_relay_list(event.deref())
.map(|(s, r)| (s.to_string(), r.clone().map(|r| r.into())))
.map(|(s, r)| (s.to_string(), r.map(|r| r.into())))
.collect()
}
2 changes: 1 addition & 1 deletion bindings/nostr-js/src/nips/nip65.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn extract_relay_list(event: &JsEvent) -> Vec<JsRelayListItem> {
nip65::extract_relay_list(event.deref())
.map(|(s, r)| JsRelayListItem {
url: s.to_string(),
metadata: r.clone().map(|r| r.into()),
metadata: r.map(|r| r.into()),
})
.collect()
}
5 changes: 3 additions & 2 deletions bindings/nostr-sdk-ffi/bindings-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ async def main():
client = Client(signer)

# Add relays and connect
await client.add_relays(["wss://relay.damus.io", "wss://nos.lol"])
await client.add_relay("wss://relay.damus.io")
await client.add_relay("wss://nos.lol")
await client.connect()

# Send an event using the Nostr Signer
Expand Down Expand Up @@ -96,4 +97,4 @@ Learn more about `rust-nostr` at <https://rust-nostr.org>.

## License

This project is distributed under the MIT software license - see the [LICENSE](https://github.com/rust-nostr/nostr/blob/master/LICENSE) file for details
This project is distributed under the MIT software license - see the [LICENSE](https://github.com/rust-nostr/nostr/blob/master/LICENSE) file for details
3 changes: 2 additions & 1 deletion bindings/nostr-sdk-ffi/bindings-python/examples/blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ async def main():

# Init client
client = Client()
await client.add_relays(["wss://relay.damus.io", "wss://nos.lol"])
await client.add_relay("wss://relay.damus.io")
await client.add_relay("wss://nos.lol")
await client.connect()

muted_public_key = PublicKey.parse("npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ async def main():
.proxy(proxy))
client = Client.with_opts(None, opts)

await client.add_relays([
"wss://relay.damus.io",
"ws://oxtrdevav64z64yb7x6rjg4ntzqjhedm5b5zjqulugknhzr46ny2qbad.onion"
])
await client.add_relay("wss://relay.damus.io")
await client.add_relay("ws://oxtrdevav64z64yb7x6rjg4ntzqjhedm5b5zjqulugknhzr46ny2qbad.onion")
await client.connect()

event = EventBuilder.text_note("Hello from Rust Nostr Python bindings!", []).to_event(keys)
Expand Down
3 changes: 2 additions & 1 deletion bindings/nostr-sdk-ffi/bindings-python/examples/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ async def main():
client = Client(signer)

# Add relays and connect
await client.add_relays(["wss://relay.damus.io", "wss://nos.lol", "wss://nostr.wine"])
await client.add_relay("wss://relay.damus.io")
await client.add_relay("wss://nos.lol")
await client.connect()

# Send an event using the Nostr Signer
Expand Down
8 changes: 3 additions & 5 deletions bindings/nostr-sdk-ffi/bindings-python/examples/tor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ async def main():
opts = Options().connection(connection).connection_timeout(timedelta(seconds=60))
client = Client.with_opts(signer, opts)

await client.add_relays([
"wss://relay.damus.io",
"ws://oxtrdevav64z64yb7x6rjg4ntzqjhedm5b5zjqulugknhzr46ny2qbad.onion",
"ws://2jsnlhfnelig5acq6iacydmzdbdmg7xwunm4xl6qwbvzacw4lwrjmlyd.onion",
])
await client.add_relay("wss://relay.damus.io")
await client.add_relay("ws://oxtrdevav64z64yb7x6rjg4ntzqjhedm5b5zjqulugknhzr46ny2qbad.onion")
await client.add_relay("ws://2jsnlhfnelig5acq6iacydmzdbdmg7xwunm4xl6qwbvzacw4lwrjmlyd.onion")
await client.connect()

event = EventBuilder.text_note("Hello from rust-nostr Python bindings!", [])
Expand Down
Loading
Loading