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
7413552a
Commit
7413552a
authored
Feb 17, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Root should reset on undo
parent
b7a636b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
trie.go
ethutil/trie.go
+7
-2
No files found.
ethutil/trie.go
View file @
7413552a
...
...
@@ -98,22 +98,25 @@ func (cache *Cache) Undo() {
// Please note that the data isn't persisted unless `Sync` is
// explicitly called.
type
Trie
struct
{
Root
interface
{}
prevRoot
interface
{}
Root
interface
{}
//db Database
cache
*
Cache
}
func
NewTrie
(
db
Database
,
Root
interface
{})
*
Trie
{
return
&
Trie
{
cache
:
NewCache
(
db
),
Root
:
Root
}
return
&
Trie
{
cache
:
NewCache
(
db
),
Root
:
Root
,
prevRoot
:
Root
}
}
// Save the cached value to the database.
func
(
t
*
Trie
)
Sync
()
{
t
.
cache
.
Commit
()
t
.
prevRoot
=
t
.
Root
}
func
(
t
*
Trie
)
Undo
()
{
t
.
cache
.
Undo
()
t
.
Root
=
t
.
prevRoot
}
/*
...
...
@@ -181,6 +184,7 @@ func (t *Trie) GetNode(node interface{}) *Value {
}
func
(
t
*
Trie
)
UpdateState
(
node
interface
{},
key
[]
int
,
value
string
)
interface
{}
{
if
value
!=
""
{
return
t
.
InsertState
(
node
,
key
,
value
)
}
else
{
...
...
@@ -241,6 +245,7 @@ func (t *Trie) InsertState(node interface{}, key []int, value interface{}) inter
// Check for "special" 2 slice type node
if
currentNode
.
Len
()
==
2
{
// Decode the key
k
:=
CompactDecode
(
currentNode
.
Get
(
0
)
.
Str
())
v
:=
currentNode
.
Get
(
1
)
.
Raw
()
...
...
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