migrate accounts to be referenced through pks instead of indices

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-06-26 14:30:26 -04:00
parent d092f5c23e
commit 10d6d740b8
11 changed files with 169 additions and 345 deletions

View File

@@ -428,8 +428,8 @@ impl Damus {
} else {
info!("DecksCache: creating new with demo configuration");
let mut cache = DecksCache::new_with_demo_config(&mut timeline_cache, ctx);
for account in ctx.accounts.get_accounts() {
cache.add_deck_default(account.key.pubkey);
for (pk, _) in &ctx.accounts.cache {
cache.add_deck_default(*pk);
}
set_demo(&mut cache, ctx.ndb, ctx.accounts, ctx.unknown_ids);
@@ -445,8 +445,6 @@ impl Damus {
let jobs = JobsCache::default();
ctx.accounts.with_fallback(FALLBACK_PUBKEY());
let threads = Threads::default();
Self {
@@ -770,13 +768,14 @@ pub fn set_demo(
accounts: &mut Accounts,
unk_ids: &mut UnknownIds,
) {
let fallback = decks_cache.get_fallback_pubkey();
let txn = Transaction::new(ndb).expect("txn");
if let Some(resp) =
accounts.add_account(Keypair::only_pubkey(*decks_cache.get_fallback_pubkey()))
{
resp.unk_id_action.process_action(unk_ids, ndb, &txn);
}
accounts.select_account(accounts.num_accounts() - 1);
accounts.select_account(fallback);
}
fn columns_to_decks_cache(cols: Columns, key: &[u8; 32]) -> DecksCache {