From e4637f51999842e8dfa45bac9f912f5d3fb5caba Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 28 Oct 2020 22:38:10 +0000 Subject: [PATCH] Revert "for revert: daft AccountName recovery" This reverts commit 1a643415fe3580cd13719f3ff19e0cd378a9d66e. --- src/accounts.rs | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/src/accounts.rs b/src/accounts.rs index ccfc0836..4ba85afc 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -168,33 +168,14 @@ pub fn save_accounts_now() -> Result<(), InternalError> { panic!("xxx") } -pub type Mut<'l> = ( - MappedRwLockWriteGuard<'l, AccountRecord>, - MappedRwLockWriteGuard<'l, AccountName>, - AccountId, -); - -trait AccountNameOrId { - fn initial_lookup(Self, accounts: &Accounts) -> Option; -} - -impl<'n> AccountNameOrId for &'n AccountName { - #[throws(as Option)] - fn lookup_mut(self, accounts: &RwLockWriteGuard) -> AccountLookupMut { - let acctid = *accounts.names.get(self)?; - -} - #[derive(Default,Debug)] -struct LookupHelper<'d> { +struct LookupHelper { acctid_r: Option, } -impl<'d, K:AccountNameOrId> LookupHelper<'d, K> { +impl LookupHelper { #[throws(as Option)] - fn get(&mut self, accounts: &Accounts, key: K) -> AccountId { - let acctid = key.initial_lookup(accounts)?; - let name = *accounts.records. + fn get(&mut self, accounts: &Accounts, account: &AccountName) -> AccountId { let acctid = *accounts.names.get(account)?; self.acctid_r = Some(acctid); acctid @@ -218,7 +199,7 @@ impl AccountRecord { }).collect() } - pub fn lookup(key: K, _: Authorisation) + pub fn lookup(account: &AccountName, _: Authorisation) -> Option<(MappedRwLockReadGuard<'static, AccountRecord>, AccountId)> { @@ -232,9 +213,10 @@ impl AccountRecord { ) } - pub fn lookup_mut_caller_must_save - ( key: &K, _auth: Authorisation) - -> Option + pub fn lookup_mut_caller_must_save + ( account: &AccountName, _auth: Authorisation) + -> Option<(MappedRwLockWriteGuard<'static, AccountRecord>, + AccountId)> { let mut helper : LookupHelper = default(); helper.wrap( -- 2.30.2