aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/presale.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-03-03 08:15:42 +0800
committerFelix Lange <fjl@twurst.com>2016-04-12 21:58:07 +0800
commita9f26dcd0d14c0cb9f309ebccf81e8f741fc4636 (patch)
tree1a1e269194f3698737b0c1dbaf918c4e8dbae347 /accounts/presale.go
parentef63e9af55fcfe3255dddec3197bd8a807152c66 (diff)
downloaddexon-a9f26dcd0d14c0cb9f309ebccf81e8f741fc4636.tar
dexon-a9f26dcd0d14c0cb9f309ebccf81e8f741fc4636.tar.gz
dexon-a9f26dcd0d14c0cb9f309ebccf81e8f741fc4636.tar.bz2
dexon-a9f26dcd0d14c0cb9f309ebccf81e8f741fc4636.tar.lz
dexon-a9f26dcd0d14c0cb9f309ebccf81e8f741fc4636.tar.xz
dexon-a9f26dcd0d14c0cb9f309ebccf81e8f741fc4636.tar.zst
dexon-a9f26dcd0d14c0cb9f309ebccf81e8f741fc4636.zip
accounts: cache key addresses
In order to avoid disk thrashing for Accounts and HasAccount, address->key file mappings are now cached in memory. This makes it no longer necessary to keep the key address in the file name. The address of each key is derived from file content instead. There are minor user-visible changes: - "geth account list" now reports key file paths alongside the address. - If multiple keys are present for an address, unlocking by address is not possible. Users are directed to remove the duplicate files instead. Unlocking by index is still possible. - Key files are overwritten written in place when updating the password.
Diffstat (limited to 'accounts/presale.go')
-rw-r--r--accounts/presale.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/accounts/presale.go b/accounts/presale.go
index 8faa98558..86bfc519c 100644
--- a/accounts/presale.go
+++ b/accounts/presale.go
@@ -31,14 +31,15 @@ import (
)
// creates a Key and stores that in the given KeyStore by decrypting a presale key JSON
-func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (*Key, error) {
+func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (Account, *Key, error) {
key, err := decryptPreSaleKey(keyJSON, password)
if err != nil {
- return nil, err
+ return Account{}, nil, err
}
key.Id = uuid.NewRandom()
- err = keyStore.StoreKey(key, password)
- return key, err
+ a := Account{Address: key.Address, File: keyStore.JoinPath(keyFileName(key.Address))}
+ err = keyStore.StoreKey(a.File, key, password)
+ return a, key, err
}
func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error) {