accounts, mobile: make account manager API a bit more uniform

This commit is contained in:
Péter Szilágyi 2017-01-17 13:25:36 +02:00
parent 26d385c18b
commit 230530f5ea
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
3 changed files with 8 additions and 8 deletions

View File

@ -113,9 +113,9 @@ func (am *Manager) Accounts() []Account {
return am.cache.accounts() return am.cache.accounts()
} }
// DeleteAccount deletes the key matched by account if the passphrase is correct. // Delete deletes the key matched by account if the passphrase is correct.
// If a contains no filename, the address must match a unique key. // If the account contains no filename, the address must match a unique key.
func (am *Manager) DeleteAccount(a Account, passphrase string) error { func (am *Manager) Delete(a Account, passphrase string) error {
// Decrypting the key isn't really necessary, but we do // Decrypting the key isn't really necessary, but we do
// it anyway to check the password and zero out the key // it anyway to check the password and zero out the key
// immediately afterwards. // immediately afterwards.

View File

@ -53,14 +53,14 @@ func TestManager(t *testing.T) {
if err := am.Update(a, "foo", "bar"); err != nil { if err := am.Update(a, "foo", "bar"); err != nil {
t.Errorf("Update error: %v", err) t.Errorf("Update error: %v", err)
} }
if err := am.DeleteAccount(a, "bar"); err != nil { if err := am.Delete(a, "bar"); err != nil {
t.Errorf("DeleteAccount error: %v", err) t.Errorf("Delete error: %v", err)
} }
if common.FileExist(a.File) { if common.FileExist(a.File) {
t.Errorf("account file %s should be gone after DeleteAccount", a.File) t.Errorf("account file %s should be gone after Delete", a.File)
} }
if am.HasAddress(a.Address) { if am.HasAddress(a.Address) {
t.Errorf("HasAccount(%x) should've returned true after DeleteAccount", a.Address) t.Errorf("HasAccount(%x) should've returned true after Delete", a.Address)
} }
} }

View File

@ -103,7 +103,7 @@ func (am *AccountManager) GetAccounts() *Accounts {
// DeleteAccount deletes the key matched by account if the passphrase is correct. // DeleteAccount deletes the key matched by account if the passphrase is correct.
// If a contains no filename, the address must match a unique key. // If a contains no filename, the address must match a unique key.
func (am *AccountManager) DeleteAccount(account *Account, passphrase string) error { func (am *AccountManager) DeleteAccount(account *Account, passphrase string) error {
return am.manager.DeleteAccount(accounts.Account{ return am.manager.Delete(accounts.Account{
Address: account.account.Address, Address: account.account.Address,
File: account.account.File, File: account.account.File,
}, passphrase) }, passphrase)