wip: refactor
This commit is contained in:
@@ -10,6 +10,7 @@ use crate::{
|
||||
|
||||
pub struct AccountRegistry {
|
||||
public_key: Option<PublicKey>,
|
||||
pub(crate) is_loading: bool,
|
||||
}
|
||||
|
||||
impl Global for AccountRegistry {}
|
||||
@@ -58,6 +59,10 @@ impl AccountRegistry {
|
||||
.detach();
|
||||
}
|
||||
|
||||
pub fn set_loading(&mut self) {
|
||||
self.is_loading = false
|
||||
}
|
||||
|
||||
pub fn get(&self) -> Option<PublicKey> {
|
||||
self.public_key
|
||||
}
|
||||
@@ -71,6 +76,9 @@ impl AccountRegistry {
|
||||
}
|
||||
|
||||
fn new() -> Self {
|
||||
Self { public_key: None }
|
||||
Self {
|
||||
public_key: None,
|
||||
is_loading: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,6 @@ impl MetadataRegistry {
|
||||
cx.set_global(Self::new());
|
||||
}
|
||||
|
||||
pub fn contains(&self, public_key: PublicKey) -> bool {
|
||||
self.seens.lock().unwrap().contains(&public_key)
|
||||
}
|
||||
|
||||
pub fn seen(&mut self, public_key: PublicKey, metadata: Option<Metadata>) {
|
||||
let mut seens = self.seens.lock().unwrap();
|
||||
|
||||
|
||||
@@ -5,14 +5,12 @@ use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Signal {
|
||||
/// Request metadata
|
||||
ReqMetadata(PublicKey),
|
||||
/// Receive metadata
|
||||
RecvMetadata(PublicKey),
|
||||
/// Receive EOSE
|
||||
RecvEose(SubscriptionId),
|
||||
Metadata(PublicKey),
|
||||
/// Receive event
|
||||
RecvEvent(Event),
|
||||
Event(Event),
|
||||
/// Receive EOSE
|
||||
Eose,
|
||||
}
|
||||
|
||||
pub struct SignalRegistry {
|
||||
|
||||
Reference in New Issue
Block a user