notedeck

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

commit 2fb2940d56c954611469de1730dcdb6eaa1ff6f1
parent 4914c637ced70c2c6697c60630f92b07f0064ee6
Author: kernelkind <kernelkind@gmail.com>
Date:   Wed, 25 Jun 2025 17:22:50 -0400

accounts: make fallback pk non optional

Note: this commit alone is *incorrect* and will cause crashes.
It is part of a greater plan to upgrade accounts. It was done this
way to break commits to smaller, more digestable chunks

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/account/accounts.rs | 20+++++++++++---------
Mcrates/notedeck/src/app.rs | 3++-
2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/crates/notedeck/src/account/accounts.rs b/crates/notedeck/src/account/accounts.rs @@ -20,11 +20,15 @@ pub struct Accounts { account_data: BTreeMap<[u8; 32], AccountData>, relay_defaults: RelayDefaults, needs_relay_config: bool, - fallback: Option<Pubkey>, + fallback: Pubkey, } impl Accounts { - pub fn new(key_store: Option<AccountStorage>, forced_relays: Vec<String>) -> Self { + pub fn new( + key_store: Option<AccountStorage>, + forced_relays: Vec<String>, + fallback: Pubkey, + ) -> Self { let accounts = match &key_store { Some(keystore) => match keystore.get_accounts() { Ok(k) => k, @@ -53,7 +57,7 @@ impl Accounts { account_data, relay_defaults, needs_relay_config: true, - fallback: None, + fallback, } } @@ -82,7 +86,7 @@ impl Accounts { } pub fn with_fallback(&mut self, fallback: Pubkey) { - self.fallback = Some(fallback); + self.fallback = fallback; } pub fn remove_account(&mut self, index: usize) { @@ -359,11 +363,9 @@ impl Accounts { } fn handle_no_accounts(&mut self, unknown_ids: &mut UnknownIds, ndb: &Ndb, txn: &Transaction) { - if let Some(fallback) = self.fallback { - self.add_account(Keypair::new(fallback, None)) - .process_action(unknown_ids, ndb, txn); - self.select_account(self.num_accounts() - 1); - } + self.add_account(Keypair::new(self.fallback, None)) + .process_action(unknown_ids, ndb, txn); + self.select_account(self.num_accounts() - 1); } fn poll_for_updates(&mut self, ndb: &Ndb) -> bool { diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs @@ -1,3 +1,4 @@ +use crate::account::FALLBACK_PUBKEY; use crate::persist::{AppSizeHandler, ZoomHandler}; use crate::wallet::GlobalWallet; use crate::zaps::Zaps; @@ -176,7 +177,7 @@ impl Notedeck { None }; - let mut accounts = Accounts::new(keystore, parsed_args.relays.clone()); + let mut accounts = Accounts::new(keystore, parsed_args.relays.clone(), FALLBACK_PUBKEY()); let num_keys = parsed_args.keys.len();