mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Update for nostr-types (RelayUsage -> RelayListUsage)
This commit is contained in:
parent
55352743ec
commit
ceb438f0fb
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2240,7 +2240,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gossip-relay-picker"
|
||||
version = "0.2.0-unstable"
|
||||
source = "git+https://github.com/mikedilger/gossip-relay-picker?rev=6a31a4f540ffc5c2928a8c9881810a12cd2cf9f4#6a31a4f540ffc5c2928a8c9881810a12cd2cf9f4"
|
||||
source = "git+https://github.com/mikedilger/gossip-relay-picker?rev=a14ced4149de06de71c1ba018db0e7691e531cea#a14ced4149de06de71c1ba018db0e7691e531cea"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"dashmap",
|
||||
@ -3233,7 +3233,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-types"
|
||||
version = "0.8.0-unstable"
|
||||
source = "git+https://github.com/mikedilger/nostr-types?rev=76084731b6be2c0203ea1111bfc2a94fd91652b9#76084731b6be2c0203ea1111bfc2a94fd91652b9"
|
||||
source = "git+https://github.com/mikedilger/nostr-types?rev=f2489722dfb4c94413d0958bd2ca75cbcc13b1d4#f2489722dfb4c94413d0958bd2ca75cbcc13b1d4"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64 0.22.1",
|
||||
|
@ -25,13 +25,13 @@ egui-winit = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0c
|
||||
egui_extras = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0cae0cb9f9465bf7273227be6c", features = [ "syntect" ] }
|
||||
#egui = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0cae0cb9f9465bf7273227be6c", features = [ "deadlock_detection" ] }
|
||||
egui-video = { git = "https://github.com/mikedilger/egui-video", rev = "97f58f88dfe912697393567830d0751676492a89", features = [ "from_bytes" ], optional = true }
|
||||
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "6a31a4f540ffc5c2928a8c9881810a12cd2cf9f4" }
|
||||
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "a14ced4149de06de71c1ba018db0e7691e531cea" }
|
||||
gossip-lib = { path = "../gossip-lib" }
|
||||
humansize = "2.1"
|
||||
image = { version = "0.24.6", features = [ "png", "jpeg" ] }
|
||||
lazy_static = "1.4"
|
||||
memoize = "0.4"
|
||||
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "76084731b6be2c0203ea1111bfc2a94fd91652b9", features = [ "speedy" ] }
|
||||
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "f2489722dfb4c94413d0958bd2ca75cbcc13b1d4", features = [ "speedy" ] }
|
||||
paste = "1.0"
|
||||
qrcode = { git = "https://github.com/mikedilger/qrcode-rust", rev = "519b77b3efa3f84961169b47d3de08c5ddd86548" }
|
||||
resvg = "0.35.0"
|
||||
|
@ -50,7 +50,7 @@ fallible-iterator = "0.2"
|
||||
filetime = "0.2"
|
||||
futures = "0.3"
|
||||
futures-util = "0.3"
|
||||
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "6a31a4f540ffc5c2928a8c9881810a12cd2cf9f4" }
|
||||
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "a14ced4149de06de71c1ba018db0e7691e531cea" }
|
||||
heed = "0.20"
|
||||
hex = "0.4"
|
||||
http = "1.0"
|
||||
@ -59,7 +59,7 @@ kamadak-exif = "0.5"
|
||||
lazy_static = "1.4"
|
||||
linkify = "0.10"
|
||||
mime = "0.3"
|
||||
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "76084731b6be2c0203ea1111bfc2a94fd91652b9", features = [ "speedy" ] }
|
||||
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "f2489722dfb4c94413d0958bd2ca75cbcc13b1d4", features = [ "speedy" ] }
|
||||
parking_lot = "0.12"
|
||||
paste = "1.0"
|
||||
rand = "0.8"
|
||||
|
@ -11,7 +11,7 @@ use async_recursion::async_recursion;
|
||||
use heed::RwTxn;
|
||||
use nostr_types::{
|
||||
Event, EventAddr, EventKind, EventReference, Filter, Id, Metadata, NostrBech32, PublicKey,
|
||||
RelayList, RelayUrl, RelayUsage, SimpleRelayList, Tag, Unixtime,
|
||||
RelayList, RelayUrl, RelayListUsage, SimpleRelayList, Tag, Unixtime,
|
||||
};
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@ -462,11 +462,11 @@ fn process_somebody_elses_contact_list(event: &Event, force: bool) -> Result<(),
|
||||
for (url, simple_relay_usage) in srl.0.iter() {
|
||||
if let Ok(relay_url) = RelayUrl::try_from_unchecked_url(url) {
|
||||
if simple_relay_usage.read && simple_relay_usage.write {
|
||||
relay_list.0.insert(relay_url, RelayUsage::Both);
|
||||
relay_list.0.insert(relay_url, RelayListUsage::Both);
|
||||
} else if simple_relay_usage.read {
|
||||
relay_list.0.insert(relay_url, RelayUsage::Inbox);
|
||||
relay_list.0.insert(relay_url, RelayListUsage::Inbox);
|
||||
} else if simple_relay_usage.write {
|
||||
relay_list.0.insert(relay_url, RelayUsage::Outbox);
|
||||
relay_list.0.insert(relay_url, RelayListUsage::Outbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::Error;
|
||||
use crate::globals::GLOBALS;
|
||||
use async_trait::async_trait;
|
||||
use gossip_relay_picker::RelayPickerHooks;
|
||||
use nostr_types::{PublicKey, RelayUrl, RelayUsage};
|
||||
use nostr_types::{PublicKey, RelayUrl, RelayListUsage};
|
||||
|
||||
/// Hooks for the relay picker
|
||||
#[derive(Default)]
|
||||
@ -20,13 +20,13 @@ impl RelayPickerHooks for Hooks {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all relays that this public key uses in the given RelayUsage
|
||||
/// Returns all relays that this public key uses in the given RelayListUsage
|
||||
async fn get_relays_for_pubkey(
|
||||
&self,
|
||||
pubkey: PublicKey,
|
||||
usage: RelayUsage,
|
||||
usage: RelayListUsage,
|
||||
) -> Result<Vec<(RelayUrl, u64)>, Error> {
|
||||
let write = usage == RelayUsage::Outbox;
|
||||
let write = usage == RelayListUsage::Outbox;
|
||||
GLOBALS.storage.get_best_relays_with_score(pubkey, write, 0)
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ use heed::types::{Bytes, Unit};
|
||||
use heed::{Database, Env, EnvFlags, EnvOpenOptions, RoTxn, RwTxn};
|
||||
use nostr_types::{
|
||||
EncryptedPrivateKey, Event, EventAddr, EventKind, EventReference, Filter, Id, MilliSatoshi,
|
||||
PublicKey, PublicKeyHex, RelayList, RelayUrl, RelayUsage, Unixtime,
|
||||
PublicKey, PublicKeyHex, RelayList, RelayUrl, RelayListUsage, Unixtime,
|
||||
};
|
||||
use paste::paste;
|
||||
use speedy::{Readable, Writable};
|
||||
@ -1019,11 +1019,11 @@ impl Storage {
|
||||
|
||||
for relay in self.filter_relays(|_| true)? {
|
||||
if relay.has_usage_bits(Relay::INBOX | Relay::OUTBOX) {
|
||||
relay_list.0.insert(relay.url, RelayUsage::Both);
|
||||
relay_list.0.insert(relay.url, RelayListUsage::Both);
|
||||
} else if relay.has_usage_bits(Relay::OUTBOX) {
|
||||
relay_list.0.insert(relay.url, RelayUsage::Outbox);
|
||||
relay_list.0.insert(relay.url, RelayListUsage::Outbox);
|
||||
} else if relay.has_usage_bits(Relay::INBOX) {
|
||||
relay_list.0.insert(relay.url, RelayUsage::Inbox);
|
||||
relay_list.0.insert(relay.url, RelayListUsage::Inbox);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1153,9 +1153,9 @@ impl Storage {
|
||||
// Set or create read relays
|
||||
for (relay_url, usage) in relay_list.0.iter() {
|
||||
let bits = match usage {
|
||||
RelayUsage::Inbox => Relay::INBOX | Relay::READ,
|
||||
RelayUsage::Outbox => Relay::OUTBOX | Relay::WRITE,
|
||||
RelayUsage::Both => {
|
||||
RelayListUsage::Inbox => Relay::INBOX | Relay::READ,
|
||||
RelayListUsage::Outbox => Relay::OUTBOX | Relay::WRITE,
|
||||
RelayListUsage::Both => {
|
||||
Relay::INBOX | Relay::OUTBOX | Relay::READ | Relay::WRITE
|
||||
}
|
||||
};
|
||||
@ -1214,8 +1214,8 @@ impl Storage {
|
||||
pubkey,
|
||||
relay_url,
|
||||
|pr| {
|
||||
pr.read = *usage == RelayUsage::Inbox || *usage == RelayUsage::Both;
|
||||
pr.write = *usage == RelayUsage::Outbox || *usage == RelayUsage::Both;
|
||||
pr.read = *usage == RelayListUsage::Inbox || *usage == RelayListUsage::Both;
|
||||
pr.write = *usage == RelayListUsage::Outbox || *usage == RelayListUsage::Both;
|
||||
},
|
||||
Some(txn),
|
||||
)?;
|
||||
|
Loading…
Reference in New Issue
Block a user