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
bf5365b3
Commit
bf5365b3
authored
Mar 03, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delet => Delete
parent
ba0a758d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
secure_trie.go
trie/secure_trie.go
+1
-1
trie_test.go
trie/trie_test.go
+32
-0
No files found.
trie/secure_trie.go
View file @
bf5365b3
...
...
@@ -27,6 +27,6 @@ func (self *SecureTrie) GetString(key string) []byte {
func
(
self
*
SecureTrie
)
Delete
(
key
[]
byte
)
Node
{
return
self
.
Trie
.
Delete
(
crypto
.
Sha3
(
key
))
}
func
(
self
*
SecureTrie
)
DeletString
(
key
string
)
Node
{
func
(
self
*
SecureTrie
)
Delet
e
String
(
key
string
)
Node
{
return
self
.
Delete
([]
byte
(
key
))
}
trie/trie_test.go
View file @
bf5365b3
...
...
@@ -19,6 +19,10 @@ func NewEmpty() *Trie {
return
New
(
nil
,
make
(
Db
))
}
func
NewEmptySecure
()
*
SecureTrie
{
return
NewSecure
(
nil
,
make
(
Db
))
}
func
TestEmptyTrie
(
t
*
testing
.
T
)
{
trie
:=
NewEmpty
()
res
:=
trie
.
Hash
()
...
...
@@ -295,3 +299,31 @@ func TestLargeData(t *testing.T) {
}
}
}
func
TestSecureDelete
(
t
*
testing
.
T
)
{
trie
:=
NewEmptySecure
()
vals
:=
[]
struct
{
k
,
v
string
}{
{
"do"
,
"verb"
},
{
"ether"
,
"wookiedoo"
},
{
"horse"
,
"stallion"
},
{
"shaman"
,
"horse"
},
{
"doge"
,
"coin"
},
{
"ether"
,
""
},
{
"dog"
,
"puppy"
},
{
"shaman"
,
""
},
}
for
_
,
val
:=
range
vals
{
if
val
.
v
!=
""
{
trie
.
UpdateString
(
val
.
k
,
val
.
v
)
}
else
{
trie
.
DeleteString
(
val
.
k
)
}
}
hash
:=
trie
.
Hash
()
exp
:=
ethutil
.
Hex2Bytes
(
"29b235a58c3c25ab83010c327d5932bcf05324b7d6b1185e650798034783ca9d"
)
if
!
bytes
.
Equal
(
hash
,
exp
)
{
t
.
Errorf
(
"expected %x got %x"
,
exp
,
hash
)
}
}
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