aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
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 /cmd
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 'cmd')
-rw-r--r--cmd/geth/accountcmd.go8
-rw-r--r--cmd/geth/accountcmd_test.go17
2 files changed, 17 insertions, 8 deletions
diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go
index 18265f251..35b6b2dd8 100644
--- a/cmd/geth/accountcmd.go
+++ b/cmd/geth/accountcmd.go
@@ -168,7 +168,7 @@ nodes.
func accountList(ctx *cli.Context) {
accman := utils.MakeAccountManager(ctx)
for i, acct := range accman.Accounts() {
- fmt.Printf("Account #%d: %x\n", i, acct)
+ fmt.Printf("Account #%d: {%x} %s\n", i, acct.Address, acct.File)
}
}
@@ -230,7 +230,7 @@ func accountCreate(ctx *cli.Context) {
if err != nil {
utils.Fatalf("Failed to create account: %v", err)
}
- fmt.Printf("Address: %x\n", account)
+ fmt.Printf("Address: {%x}\n", account.Address)
}
// accountUpdate transitions an account from a previous format to the current
@@ -265,7 +265,7 @@ func importWallet(ctx *cli.Context) {
if err != nil {
utils.Fatalf("Could not create the account: %v", err)
}
- fmt.Printf("Address: %x\n", acct)
+ fmt.Printf("Address: {%x}\n", acct.Address)
}
func accountImport(ctx *cli.Context) {
@@ -279,5 +279,5 @@ func accountImport(ctx *cli.Context) {
if err != nil {
utils.Fatalf("Could not create the account: %v", err)
}
- fmt.Printf("Address: %x\n", acct)
+ fmt.Printf("Address: {%x}\n", acct.Address)
}
diff --git a/cmd/geth/accountcmd_test.go b/cmd/geth/accountcmd_test.go
index 4b8a80855..7a1bf4ea1 100644
--- a/cmd/geth/accountcmd_test.go
+++ b/cmd/geth/accountcmd_test.go
@@ -19,6 +19,7 @@ package main
import (
"io/ioutil"
"path/filepath"
+ "runtime"
"strings"
"testing"
@@ -50,11 +51,19 @@ func TestAccountList(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
geth := runGeth(t, "--datadir", datadir, "account")
defer geth.expectExit()
- geth.expect(`
-Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8}
-Account #1: {f466859ead1932d743d622cb74fc058882e8648a}
-Account #2: {289d485d9771714cce91d3393d764e1311907acc}
+ if runtime.GOOS == "windows" {
+ geth.expect(`
+Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} {{.Datadir}}\keystore\UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
+Account #1: {f466859ead1932d743d622cb74fc058882e8648a} {{.Datadir}}\keystore\aaa
+Account #2: {289d485d9771714cce91d3393d764e1311907acc} {{.Datadir}}\keystore\zzz
+`)
+ } else {
+ geth.expect(`
+Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} {{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
+Account #1: {f466859ead1932d743d622cb74fc058882e8648a} {{.Datadir}}/keystore/aaa
+Account #2: {289d485d9771714cce91d3393d764e1311907acc} {{.Datadir}}/keystore/zzz
`)
+ }
}
func TestAccountNew(t *testing.T) {