Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
exchain
nebula
Commits
6842f478
Commit
6842f478
authored
Sep 25, 2021
by
han0110
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: only add pair when position seen in key
parent
0e6ad3bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
database.go
minigeth/trie/database.go
+11
-4
trie.go
minigeth/trie/trie.go
+3
-0
No files found.
minigeth/trie/database.go
View file @
6842f478
...
...
@@ -65,19 +65,27 @@ func (db *Database) insert(hash common.Hash, size int, node node) {
//fmt.Println("insert", hash, size)
}
// TODO: Create pairs only when seeing pos
func
genPossibleShortNodePreimage
(
pos
int
)
{
preimages
:=
oracle
.
Preimages
()
newPreimages
:=
make
(
map
[
common
.
Hash
][]
byte
)
for
_
,
val
:=
range
preimages
{
node
,
err
:=
decodeNode
(
nil
,
val
)
if
err
!=
nil
{
continue
}
if
node
,
ok
:=
node
.
(
*
shortNode
);
ok
{
for
i
:=
1
;
i
<
len
(
node
.
Key
);
i
+=
1
{
var
begins
[]
int
for
i
:=
range
node
.
Key
{
if
node
.
Key
[
i
]
==
byte
(
pos
)
&&
i
+
2
<
len
(
node
.
Key
)
{
begins
=
append
(
begins
,
i
+
1
)
}
}
for
_
,
begin
:=
range
begins
{
n
:=
shortNode
{
Key
:
hexToCompact
(
node
.
Key
[
len
(
node
.
Key
)
-
i
:
]),
Key
:
hexToCompact
(
node
.
Key
[
begin
:
]),
Val
:
node
.
Val
,
}
buf
:=
new
(
bytes
.
Buffer
)
...
...
@@ -88,7 +96,6 @@ func genPossibleShortNodePreimage(pos int) {
if
len
(
preimage
)
<
32
{
continue
}
newPreimages
[
crypto
.
Keccak256Hash
(
preimage
)]
=
preimage
}
}
...
...
minigeth/trie/trie.go
View file @
6842f478
...
...
@@ -445,6 +445,9 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
// TODO: Try to cache short nodes already generated
genPossibleShortNodePreimage
(
pos
)
// TODO: We might want to ignore this error and remove the panic in oracle.Preimage
// in case the sister node in deletion is an extension node.
// remove this optimisticly? if it's not a shortNode, it doesn't do anything
cnode
,
err
:=
t
.
resolve
(
n
.
Children
[
pos
],
prefix
)
if
err
!=
nil
{
...
...
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