notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

relay_generation.rs (1606B)


      1 use crate::relay_pool_manager::create_wakeup;
      2 use enostr::{Pubkey, RelayPool};
      3 use tracing::error;
      4 
      5 pub enum RelayGenerator {
      6     GossipModel,
      7     Nip65,
      8     Constant,
      9 }
     10 
     11 impl RelayGenerator {
     12     pub fn generate_relays_for(&self, key: &Pubkey, ctx: &egui::Context) -> RelayPool {
     13         match self {
     14             Self::GossipModel => generate_relays_gossip(key, ctx),
     15             Self::Nip65 => generate_relays_nip65(key, ctx),
     16             Self::Constant => generate_constant_relays(ctx),
     17         }
     18     }
     19 }
     20 
     21 fn generate_relays_gossip(key: &Pubkey, ctx: &egui::Context) -> RelayPool {
     22     let _ = ctx;
     23     let _ = key;
     24     todo!()
     25 }
     26 
     27 fn generate_relays_nip65(key: &Pubkey, ctx: &egui::Context) -> RelayPool {
     28     let _ = ctx;
     29     let _ = key;
     30     todo!()
     31 }
     32 
     33 fn generate_constant_relays(ctx: &egui::Context) -> RelayPool {
     34     let mut pool = RelayPool::new();
     35     let wakeup = create_wakeup(ctx);
     36 
     37     if let Err(e) = pool.add_url("ws://localhost:8080".to_string(), wakeup.clone()) {
     38         error!("{:?}", e)
     39     }
     40     if let Err(e) = pool.add_url("wss://relay.damus.io".to_string(), wakeup.clone()) {
     41         error!("{:?}", e)
     42     }
     43     if let Err(e) = pool.add_url("wss://pyramid.fiatjaf.com".to_string(), wakeup.clone()) {
     44         error!("{:?}", e)
     45     }
     46     if let Err(e) = pool.add_url("wss://nos.lol".to_string(), wakeup.clone()) {
     47         error!("{:?}", e)
     48     }
     49     if let Err(e) = pool.add_url("wss://nostr.wine".to_string(), wakeup.clone()) {
     50         error!("{:?}", e)
     51     }
     52     if let Err(e) = pool.add_url("wss://purplepag.es".to_string(), wakeup) {
     53         error!("{:?}", e)
     54     }
     55 
     56     pool
     57 }