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.
This commit is contained in:
Felix Lange
2016-03-03 01:15:42 +01:00
parent ef63e9af55
commit a9f26dcd0d
18 changed files with 1060 additions and 371 deletions

View File

@ -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)
}