debug: add subid debugging
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
29
src/app.rs
29
src/app.rs
@@ -68,6 +68,7 @@ pub struct Damus {
|
|||||||
|
|
||||||
// TODO: make these flags
|
// TODO: make these flags
|
||||||
is_mobile: bool,
|
is_mobile: bool,
|
||||||
|
pub debug: bool,
|
||||||
pub since_optimize: bool,
|
pub since_optimize: bool,
|
||||||
pub textmode: bool,
|
pub textmode: bool,
|
||||||
pub show_account_switcher: bool,
|
pub show_account_switcher: bool,
|
||||||
@@ -148,7 +149,7 @@ fn send_initial_timeline_filter(damus: &mut Damus, timeline: usize) {
|
|||||||
filter
|
filter
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let sub_id = Uuid::new_v4().to_string();
|
let sub_id = damus.gen_subid(&SubKind::Initial);
|
||||||
damus
|
damus
|
||||||
.subscriptions()
|
.subscriptions()
|
||||||
.insert(sub_id.clone(), SubKind::Initial);
|
.insert(sub_id.clone(), SubKind::Initial);
|
||||||
@@ -158,16 +159,15 @@ fn send_initial_timeline_filter(damus: &mut Damus, timeline: usize) {
|
|||||||
|
|
||||||
// we need some data first
|
// we need some data first
|
||||||
FilterState::NeedsRemote(filter) => {
|
FilterState::NeedsRemote(filter) => {
|
||||||
let sub_id = Uuid::new_v4().to_string();
|
|
||||||
let uid = damus.timelines[timeline].uid;
|
let uid = damus.timelines[timeline].uid;
|
||||||
|
let sub_kind = SubKind::FetchingContactList(uid);
|
||||||
|
let sub_id = damus.gen_subid(&sub_kind);
|
||||||
let local_sub = damus.ndb.subscribe(&filter).expect("sub");
|
let local_sub = damus.ndb.subscribe(&filter).expect("sub");
|
||||||
|
|
||||||
damus.timelines[timeline].filter =
|
damus.timelines[timeline].filter =
|
||||||
FilterState::fetching_remote(sub_id.clone(), local_sub);
|
FilterState::fetching_remote(sub_id.clone(), local_sub);
|
||||||
|
|
||||||
damus
|
damus.subscriptions().insert(sub_id.clone(), sub_kind);
|
||||||
.subscriptions()
|
|
||||||
.insert(sub_id.clone(), SubKind::FetchingContactList(uid));
|
|
||||||
|
|
||||||
damus.pool.subscribe(sub_id, filter.to_owned());
|
damus.pool.subscribe(sub_id, filter.to_owned());
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,8 @@ fn is_timeline_ready(damus: &mut Damus, timeline: usize) -> Result<bool> {
|
|||||||
setup_initial_timeline(damus, timeline, &filter).expect("setup init");
|
setup_initial_timeline(damus, timeline, &filter).expect("setup init");
|
||||||
damus.timelines[timeline].filter = FilterState::ready(filter.clone());
|
damus.timelines[timeline].filter = FilterState::ready(filter.clone());
|
||||||
|
|
||||||
let subid = Uuid::new_v4().to_string();
|
let ck = &damus.timelines[timeline].kind;
|
||||||
|
let subid = damus.gen_subid(&SubKind::Column(ck.clone()));
|
||||||
damus.pool.subscribe(subid, filter)
|
damus.pool.subscribe(subid, filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -457,6 +458,9 @@ fn handle_eose(damus: &mut Damus, subid: &str, relay_url: &str) -> Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match *sub_kind {
|
match *sub_kind {
|
||||||
|
SubKind::Column(_) => {
|
||||||
|
// eose on column? whatevs
|
||||||
|
}
|
||||||
SubKind::Initial => {
|
SubKind::Initial => {
|
||||||
let txn = Transaction::new(&damus.ndb)?;
|
let txn = Transaction::new(&damus.ndb)?;
|
||||||
UnknownIds::update(&txn, damus);
|
UnknownIds::update(&txn, damus);
|
||||||
@@ -637,8 +641,11 @@ impl Damus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let debug = parsed_args.debug;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
pool,
|
pool,
|
||||||
|
debug,
|
||||||
is_mobile,
|
is_mobile,
|
||||||
unknown_ids: UnknownIds::default(),
|
unknown_ids: UnknownIds::default(),
|
||||||
subscriptions: Subscriptions::default(),
|
subscriptions: Subscriptions::default(),
|
||||||
@@ -660,6 +667,14 @@ impl Damus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn gen_subid(&self, kind: &SubKind) -> String {
|
||||||
|
if self.debug {
|
||||||
|
format!("{:?}", kind)
|
||||||
|
} else {
|
||||||
|
Uuid::new_v4().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mock<P: AsRef<Path>>(data_path: P, is_mobile: bool) -> Self {
|
pub fn mock<P: AsRef<Path>>(data_path: P, is_mobile: bool) -> Self {
|
||||||
let mut timelines: Vec<Timeline> = vec![];
|
let mut timelines: Vec<Timeline> = vec![];
|
||||||
let filter = Filter::from_json(include_str!("../queries/global.json")).unwrap();
|
let filter = Filter::from_json(include_str!("../queries/global.json")).unwrap();
|
||||||
@@ -670,11 +685,13 @@ impl Damus {
|
|||||||
|
|
||||||
let imgcache_dir = data_path.as_ref().join(ImageCache::rel_datadir());
|
let imgcache_dir = data_path.as_ref().join(ImageCache::rel_datadir());
|
||||||
let _ = std::fs::create_dir_all(imgcache_dir.clone());
|
let _ = std::fs::create_dir_all(imgcache_dir.clone());
|
||||||
|
let debug = true;
|
||||||
|
|
||||||
let mut config = Config::new();
|
let mut config = Config::new();
|
||||||
config.set_ingester_threads(2);
|
config.set_ingester_threads(2);
|
||||||
Self {
|
Self {
|
||||||
is_mobile,
|
is_mobile,
|
||||||
|
debug,
|
||||||
unknown_ids: UnknownIds::default(),
|
unknown_ids: UnknownIds::default(),
|
||||||
subscriptions: Subscriptions::default(),
|
subscriptions: Subscriptions::default(),
|
||||||
since_optimize: true,
|
since_optimize: true,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ pub struct Args {
|
|||||||
pub keys: Vec<Keypair>,
|
pub keys: Vec<Keypair>,
|
||||||
pub since_optimize: bool,
|
pub since_optimize: bool,
|
||||||
pub light: bool,
|
pub light: bool,
|
||||||
|
pub debug: bool,
|
||||||
pub dbpath: Option<String>,
|
pub dbpath: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ impl Args {
|
|||||||
keys: vec![],
|
keys: vec![],
|
||||||
light: false,
|
light: false,
|
||||||
since_optimize: true,
|
since_optimize: true,
|
||||||
|
debug: false,
|
||||||
dbpath: None,
|
dbpath: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,6 +40,8 @@ impl Args {
|
|||||||
res.light = true;
|
res.light = true;
|
||||||
} else if arg == "--dark" {
|
} else if arg == "--dark" {
|
||||||
res.light = false;
|
res.light = false;
|
||||||
|
} else if arg == "--debug" {
|
||||||
|
res.debug = true;
|
||||||
} else if arg == "--pub" || arg == "--npub" {
|
} else if arg == "--pub" || arg == "--npub" {
|
||||||
i += 1;
|
i += 1;
|
||||||
let pubstr = if let Some(next_arg) = args.get(i) {
|
let pubstr = if let Some(next_arg) = args.get(i) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub enum PubkeySource {
|
|||||||
DeckAuthor,
|
DeckAuthor,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ListKind {
|
pub enum ListKind {
|
||||||
Contact(PubkeySource),
|
Contact(PubkeySource),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use crate::column::ColumnKind;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub enum SubKind {
|
pub enum SubKind {
|
||||||
/// Initial subscription. This is the first time we do a remote subscription
|
/// Initial subscription. This is the first time we do a remote subscription
|
||||||
/// for a timeline
|
/// for a timeline
|
||||||
@@ -8,6 +10,8 @@ pub enum SubKind {
|
|||||||
/// One shot requests, we can just close after we receive EOSE
|
/// One shot requests, we can just close after we receive EOSE
|
||||||
OneShot,
|
OneShot,
|
||||||
|
|
||||||
|
Column(ColumnKind),
|
||||||
|
|
||||||
/// We are fetching a contact list so that we can use it for our follows
|
/// We are fetching a contact list so that we can use it for our follows
|
||||||
/// Filter.
|
/// Filter.
|
||||||
// TODO: generalize this to any list?
|
// TODO: generalize this to any list?
|
||||||
|
|||||||
Reference in New Issue
Block a user