Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
a4df9d74
Commit
a4df9d74
authored
Jun 21, 2015
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts order by keyfile ctime
parent
eb82ca45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
js_test.go
cmd/geth/js_test.go
+3
-3
key_store_plain.go
crypto/key_store_plain.go
+25
-2
No files found.
cmd/geth/js_test.go
View file @
a4df9d74
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"runtime"
"runtime"
"strconv"
"strconv"
"testing"
"testing"
"time"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
...
@@ -20,8 +21,8 @@ import (
...
@@ -20,8 +21,8 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/rpc/comms"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/comms"
)
)
const
(
const
(
...
@@ -141,7 +142,6 @@ func TestAccounts(t *testing.T) {
...
@@ -141,7 +142,6 @@ func TestAccounts(t *testing.T) {
checkEvalJSON
(
t
,
repl
,
`eth.accounts`
,
`["`
+
testAddress
+
`"]`
)
checkEvalJSON
(
t
,
repl
,
`eth.accounts`
,
`["`
+
testAddress
+
`"]`
)
checkEvalJSON
(
t
,
repl
,
`eth.coinbase`
,
`null`
)
checkEvalJSON
(
t
,
repl
,
`eth.coinbase`
,
`null`
)
val
,
err
:=
repl
.
re
.
Run
(
`personal.newAccount("password")`
)
val
,
err
:=
repl
.
re
.
Run
(
`personal.newAccount("password")`
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
t
.
Errorf
(
"expected no error, got %v"
,
err
)
...
@@ -151,7 +151,7 @@ func TestAccounts(t *testing.T) {
...
@@ -151,7 +151,7 @@ func TestAccounts(t *testing.T) {
t
.
Errorf
(
"address not hex: %q"
,
addr
)
t
.
Errorf
(
"address not hex: %q"
,
addr
)
}
}
// checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`",
"`+addr+`"]`)
checkEvalJSON
(
t
,
repl
,
`eth.accounts`
,
`["`
+
testAddress
+
`",
"`
+
addr
+
`"]`
)
}
}
func
TestBlockChain
(
t
*
testing
.
T
)
{
func
TestBlockChain
(
t
*
testing
.
T
)
{
...
...
crypto/key_store_plain.go
View file @
a4df9d74
...
@@ -27,11 +27,15 @@ import (
...
@@ -27,11 +27,15 @@ import (
"encoding/hex"
"encoding/hex"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/ethereum/go-ethereum/common"
"io"
"io"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
"sort"
"syscall"
"time"
"github.com/ethereum/go-ethereum/common"
)
)
// TODO: rename to KeyStore when replacing existing KeyStore
// TODO: rename to KeyStore when replacing existing KeyStore
...
@@ -118,8 +122,15 @@ func GetKeyAddresses(keysDirPath string) (addresses []common.Address, err error)
...
@@ -118,8 +122,15 @@ func GetKeyAddresses(keysDirPath string) (addresses []common.Address, err error)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
kfis
keyFileInfos
for
_
,
fileInfo
:=
range
fileInfos
{
for
_
,
fileInfo
:=
range
fileInfos
{
address
,
err
:=
hex
.
DecodeString
(
fileInfo
.
Name
())
stat
:=
fileInfo
.
Sys
()
.
(
*
syscall
.
Stat_t
)
ctime
:=
time
.
Unix
(
int64
(
stat
.
Ctimespec
.
Sec
),
int64
(
stat
.
Ctimespec
.
Nsec
))
kfis
=
append
(
kfis
,
keyFileInfo
{
fileInfo
.
Name
(),
ctime
})
}
sort
.
Sort
(
kfis
)
for
_
,
kfi
:=
range
kfis
{
address
,
err
:=
hex
.
DecodeString
(
kfi
.
name
)
if
err
!=
nil
{
if
err
!=
nil
{
continue
continue
}
}
...
@@ -127,3 +138,15 @@ func GetKeyAddresses(keysDirPath string) (addresses []common.Address, err error)
...
@@ -127,3 +138,15 @@ func GetKeyAddresses(keysDirPath string) (addresses []common.Address, err error)
}
}
return
addresses
,
err
return
addresses
,
err
}
}
type
keyFileInfo
struct
{
name
string
ctime
time
.
Time
}
type
keyFileInfos
[]
keyFileInfo
func
(
a
keyFileInfos
)
Len
()
int
{
return
len
(
a
)
}
func
(
a
keyFileInfos
)
Swap
(
i
,
j
int
)
{
a
[
i
],
a
[
j
]
=
a
[
j
],
a
[
i
]
}
func
(
a
keyFileInfos
)
Less
(
i
,
j
int
)
bool
{
return
a
[
i
]
.
ctime
.
Before
(
a
[
j
]
.
ctime
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment