initial refactor in preparation for routing

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-05-27 12:22:40 -07:00
parent df0377cb89
commit 31b2b5c950
19 changed files with 332 additions and 587 deletions

View File

@@ -1,45 +1,7 @@
use enostr::{Pubkey, RelayPool};
use enostr::RelayPool;
use tracing::error;
pub enum RelayGenerator {
GossipModel,
Nip65,
Constant,
}
impl RelayGenerator {
pub fn generate_relays_for(
&self,
key: &Pubkey,
wakeup: impl Fn() + Send + Sync + Clone + 'static,
) -> RelayPool {
match self {
Self::GossipModel => generate_relays_gossip(key, wakeup),
Self::Nip65 => generate_relays_nip65(key, wakeup),
Self::Constant => generate_constant_relays(wakeup),
}
}
}
fn generate_relays_gossip(
key: &Pubkey,
wakeup: impl Fn() + Send + Sync + Clone + 'static,
) -> RelayPool {
let _ = wakeup;
let _ = key;
todo!()
}
fn generate_relays_nip65(
key: &Pubkey,
wakeup: impl Fn() + Send + Sync + Clone + 'static,
) -> RelayPool {
let _ = wakeup;
let _ = key;
todo!()
}
fn generate_constant_relays(wakeup: impl Fn() + Send + Sync + Clone + 'static) -> RelayPool {
fn test_relay_pool(wakeup: impl Fn() + Send + Sync + Clone + 'static) -> RelayPool {
let mut pool = RelayPool::new();
if let Err(e) = pool.add_url("ws://localhost:8080".to_string(), wakeup.clone()) {