From afc530ea411e18223b0323d7e11aa0fab9289d65 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sun, 8 Mar 2015 00:35:23 +0100 Subject: accounts: use time.Duration correctly There is no point to using time.Duration if the value is interpreted as milliseconds. Callers should use the standard multiplication idiom to choose the unit. In fact, the only caller outside of the tests already does so. --- accounts/account_manager.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'accounts/account_manager.go') diff --git a/accounts/account_manager.go b/accounts/account_manager.go index 86f9c5916..f87cce65f 100644 --- a/accounts/account_manager.go +++ b/accounts/account_manager.go @@ -33,6 +33,7 @@ and accounts persistence is derived from stored keys' addresses package accounts import ( + "crypto/ecdsa" crand "crypto/rand" "errors" @@ -52,17 +53,17 @@ type Account struct { } type AccountManager struct { - keyStore crypto.KeyStore2 - unlockedKeys map[string]crypto.Key - unlockMilliseconds time.Duration - mutex sync.RWMutex + keyStore crypto.KeyStore2 + unlockedKeys map[string]crypto.Key + unlockTime time.Duration + mutex sync.RWMutex } -func NewAccountManager(keyStore crypto.KeyStore2, unlockMilliseconds time.Duration) *AccountManager { +func NewAccountManager(keyStore crypto.KeyStore2, unlockTime time.Duration) *AccountManager { return &AccountManager{ - keyStore: keyStore, - unlockedKeys: make(map[string]crypto.Key), - unlockMilliseconds: unlockMilliseconds, + keyStore: keyStore, + unlockedKeys: make(map[string]crypto.Key), + unlockTime: unlockTime, } } @@ -144,7 +145,7 @@ func (am *AccountManager) Accounts() ([]Account, error) { func unlockLater(am *AccountManager, addr []byte) { select { - case <-time.After(time.Millisecond * am.unlockMilliseconds): + case <-time.After(am.unlockTime): } am.mutex.RLock() // TODO: how do we know the key is actually gone from memory? -- cgit