aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/account_manager.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-08 07:35:23 +0800
committerFelix Lange <fjl@twurst.com>2015-03-08 07:35:23 +0800
commitafc530ea411e18223b0323d7e11aa0fab9289d65 (patch)
treeeaae979f2f1b78fd51a0c03e750544b96e27ef62 /accounts/account_manager.go
parentfda7b4c79d070f1cb4f5d7ef5b4d077d9dcf2774 (diff)
downloaddexon-afc530ea411e18223b0323d7e11aa0fab9289d65.tar
dexon-afc530ea411e18223b0323d7e11aa0fab9289d65.tar.gz
dexon-afc530ea411e18223b0323d7e11aa0fab9289d65.tar.bz2
dexon-afc530ea411e18223b0323d7e11aa0fab9289d65.tar.lz
dexon-afc530ea411e18223b0323d7e11aa0fab9289d65.tar.xz
dexon-afc530ea411e18223b0323d7e11aa0fab9289d65.tar.zst
dexon-afc530ea411e18223b0323d7e11aa0fab9289d65.zip
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.
Diffstat (limited to 'accounts/account_manager.go')
-rw-r--r--accounts/account_manager.go19
1 files changed, 10 insertions, 9 deletions
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?