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
3220a32f
Commit
3220a32f
authored
Nov 18, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some comparison tests for the new ptrie
parent
f7417d35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
trie.go
trie/trie.go
+6
-1
trie_test.go
trie/trie_test.go
+56
-0
No files found.
trie/trie.go
View file @
3220a32f
...
...
@@ -197,7 +197,12 @@ func (t *Trie) Update(key, value string) {
k
:=
CompactHexDecode
(
key
)
root
:=
t
.
UpdateState
(
t
.
Root
,
k
,
value
)
var
root
interface
{}
if
value
!=
""
{
root
=
t
.
UpdateState
(
t
.
Root
,
k
,
value
)
}
else
{
root
=
t
.
deleteState
(
t
.
Root
,
k
)
}
t
.
setRoot
(
root
)
}
...
...
trie/trie_test.go
View file @
3220a32f
...
...
@@ -444,3 +444,59 @@ func TestRndCase(t *testing.T) {
fmt.Printf("%x\n", trie.Get(string(ethutil.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))))
}
*/
func
TestOtherSomething
(
t
*
testing
.
T
)
{
_
,
trie
:=
NewTrie
()
vals
:=
[]
struct
{
k
,
v
string
}{
{
"do"
,
"verb"
},
{
"ether"
,
"wookiedoo"
},
{
"horse"
,
"stallion"
},
{
"shaman"
,
"horse"
},
{
"doge"
,
"coin"
},
{
"ether"
,
""
},
{
"dog"
,
"puppy"
},
{
"shaman"
,
""
},
}
for
_
,
val
:=
range
vals
{
trie
.
Update
(
val
.
k
,
val
.
v
)
}
exp
:=
ethutil
.
Hex2Bytes
(
"5991bb8c6514148a29db676a14ac506cd2cd5775ace63c30a4fe457715e9ac84"
)
hash
:=
trie
.
Root
.
([]
byte
)
if
!
bytes
.
Equal
(
hash
,
exp
)
{
t
.
Errorf
(
"expected %x got %x"
,
exp
,
hash
)
}
}
func
BenchmarkGets
(
b
*
testing
.
B
)
{
_
,
trie
:=
NewTrie
()
vals
:=
[]
struct
{
k
,
v
string
}{
{
"do"
,
"verb"
},
{
"ether"
,
"wookiedoo"
},
{
"horse"
,
"stallion"
},
{
"shaman"
,
"horse"
},
{
"doge"
,
"coin"
},
{
"ether"
,
""
},
{
"dog"
,
"puppy"
},
{
"shaman"
,
""
},
{
"somethingveryoddindeedthis is"
,
"myothernodedata"
},
}
for
_
,
val
:=
range
vals
{
trie
.
Update
(
val
.
k
,
val
.
v
)
}
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
trie
.
Get
(
"horse"
)
}
}
func
BenchmarkUpdate
(
b
*
testing
.
B
)
{
_
,
trie
:=
NewTrie
()
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
trie
.
Update
(
fmt
.
Sprintf
(
"aaaaaaaaaaaaaaa%d"
,
j
),
"value"
)
}
}
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