fix: update to nostr sdk 0.38
This commit is contained in:
parent
50503f7f66
commit
9ea491a301
5 changed files with 568 additions and 343 deletions
874
Cargo.lock
generated
874
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
10
Cargo.toml
10
Cargo.toml
|
@ -13,14 +13,15 @@ default-run = "mostr"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
nostr-sdk = "0.38"
|
||||||
# Basics
|
# Basics
|
||||||
tokio = { version = "1.42", features = ["rt", "rt-multi-thread", "macros"] }
|
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
|
||||||
regex = "1.10.6"
|
regex = "1.11"
|
||||||
# System
|
# System
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
colog = "1.3"
|
colog = "1.3"
|
||||||
colored = "2.1"
|
colored = "2.2"
|
||||||
rustyline = { git = "https://github.com/xeruf/rustyline", rev = "465b14d" }
|
rustyline = { git = "https://github.com/xeruf/rustyline", rev = "465b14d" }
|
||||||
# OS-Specific Abstractions
|
# OS-Specific Abstractions
|
||||||
keyring = "3"
|
keyring = "3"
|
||||||
|
@ -30,9 +31,8 @@ whoami = "1.5"
|
||||||
# Application Utils
|
# Application Utils
|
||||||
itertools = "0.12"
|
itertools = "0.12"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
parse_datetime = "0.5.0"
|
parse_datetime = "0.5"
|
||||||
interim = { version = "0.1", features = ["chrono"] }
|
interim = { version = "0.1", features = ["chrono"] }
|
||||||
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "e82bc787bdd8490ceadb034fe4483e4df1e91b2a" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
mostr = { path = ".", default-features = false }
|
mostr = { path = ".", default-features = false }
|
||||||
|
|
|
@ -14,21 +14,21 @@ const UNDO_DELAY: u64 = 60;
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub(crate) enum MostrMessage {
|
pub(crate) enum MostrMessage {
|
||||||
Flush,
|
Flush,
|
||||||
NewRelay(Url),
|
NewRelay(RelayUrl),
|
||||||
AddTasks(Url, Vec<Event>),
|
AddTasks(RelayUrl, Vec<Event>),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Events = Vec<Event>;
|
type Events = Vec<Event>;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct EventSender {
|
pub(crate) struct EventSender {
|
||||||
pub(crate) url: Option<Url>,
|
pub(crate) url: Option<RelayUrl>,
|
||||||
pub(crate) tx: Sender<MostrMessage>,
|
pub(crate) tx: Sender<MostrMessage>,
|
||||||
pub(crate) keys: Keys,
|
pub(crate) keys: Keys,
|
||||||
pub(crate) queue: RefCell<Events>,
|
pub(crate) queue: RefCell<Events>,
|
||||||
}
|
}
|
||||||
impl EventSender {
|
impl EventSender {
|
||||||
pub(crate) fn from(url: Option<Url>, tx: &Sender<MostrMessage>, keys: &Keys) -> Self {
|
pub(crate) fn from(url: Option<RelayUrl>, tx: &Sender<MostrMessage>, keys: &Keys) -> Self {
|
||||||
EventSender {
|
EventSender {
|
||||||
url,
|
url,
|
||||||
tx: tx.clone(),
|
tx: tx.clone(),
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -206,12 +206,12 @@ async fn main() -> Result<()> {
|
||||||
let metadata_clone = metadata.clone();
|
let metadata_clone = metadata.clone();
|
||||||
|
|
||||||
let (tx, mut rx) = mpsc::channel::<MostrMessage>(64);
|
let (tx, mut rx) = mpsc::channel::<MostrMessage>(64);
|
||||||
let tasks_for_url = |url: Option<Url>| TasksRelay::from(url, &tx, &keys, Some(metadata.clone()));
|
let tasks_for_url = |url: Option<RelayUrl>| TasksRelay::from(url, &tx, &keys, Some(metadata.clone()));
|
||||||
let mut relays: HashMap<Option<Url>, TasksRelay> =
|
let mut relays: HashMap<Option<RelayUrl>, TasksRelay> =
|
||||||
client.relays().await.into_keys().map(|url| (Some(url.clone()), tasks_for_url(Some(url)))).collect();
|
client.relays().await.into_keys().map(|url| (Some(url.clone()), tasks_for_url(Some(url)))).collect();
|
||||||
|
|
||||||
let sender = tokio::spawn(async move {
|
let sender = tokio::spawn(async move {
|
||||||
let mut queue: Option<(Url, Vec<Event>)> = None;
|
let mut queue: Option<(RelayUrl, Vec<Event>)> = None;
|
||||||
|
|
||||||
or_warn!(client.set_metadata(&metadata_clone).await, "Unable to set metadata");
|
or_warn!(client.set_metadata(&metadata_clone).await, "Unable to set metadata");
|
||||||
|
|
||||||
|
@ -267,9 +267,7 @@ async fn main() -> Result<()> {
|
||||||
if relays.is_empty() {
|
if relays.is_empty() {
|
||||||
relays.insert(None, tasks_for_url(None));
|
relays.insert(None, tasks_for_url(None));
|
||||||
}
|
}
|
||||||
let mut selected_relay: Option<Url> = relays.keys()
|
let mut selected_relay: Option<RelayUrl> = relays.keys().next().unwrap().clone();
|
||||||
.find_or_first(|url| url.as_ref().is_some_and(|u| u.scheme() == "wss"))
|
|
||||||
.unwrap().clone();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let tasks = relays.get_mut(&selected_relay).unwrap();
|
let tasks = relays.get_mut(&selected_relay).unwrap();
|
||||||
|
@ -734,7 +732,7 @@ async fn main() -> Result<()> {
|
||||||
println!("{}", tasks);
|
println!("{}", tasks);
|
||||||
continue 'repl;
|
continue 'repl;
|
||||||
}
|
}
|
||||||
or_warn!(Url::parse(&command), "Failed to parse url {}", command).map(|url| {
|
or_warn!(RelayUrl::parse(&command), "Failed to parse url {}", command).map(|url| {
|
||||||
match tx.try_send(MostrMessage::NewRelay(url.clone())) {
|
match tx.try_send(MostrMessage::NewRelay(url.clone())) {
|
||||||
Err(e) => error!("Nostr communication thread failure, cannot add relay \"{url}\": {e}"),
|
Err(e) => error!("Nostr communication thread failure, cannot add relay \"{url}\": {e}"),
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
|
|
@ -20,10 +20,7 @@ use chrono::{Local, TimeDelta};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::{debug, error, info, trace, warn};
|
use log::{debug, error, info, trace, warn};
|
||||||
use nostr_sdk::{
|
use nostr_sdk::{Alphabet, Event, EventBuilder, EventId, JsonUtil, Keys, Kind, Metadata, PublicKey, RelayUrl, SingleLetterTag, Tag, TagKind, Timestamp, Url};
|
||||||
Alphabet, Event, EventBuilder, EventId, JsonUtil, Keys, Kind, Metadata, PublicKey,
|
|
||||||
SingleLetterTag, Tag, TagKind, Timestamp, Url,
|
|
||||||
};
|
|
||||||
use regex::bytes::Regex;
|
use regex::bytes::Regex;
|
||||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
|
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
|
@ -155,7 +152,7 @@ impl Display for StateFilter {
|
||||||
|
|
||||||
impl TasksRelay {
|
impl TasksRelay {
|
||||||
pub(crate) fn from(
|
pub(crate) fn from(
|
||||||
url: Option<Url>,
|
url: Option<RelayUrl>,
|
||||||
tx: &Sender<MostrMessage>,
|
tx: &Sender<MostrMessage>,
|
||||||
keys: &Keys,
|
keys: &Keys,
|
||||||
metadata: Option<Metadata>,
|
metadata: Option<Metadata>,
|
||||||
|
|
Loading…
Add table
Reference in a new issue