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
514a9472
Commit
514a9472
authored
Feb 19, 2019
by
Matthew Halpern
Committed by
Felix Lange
Feb 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trie: prefer nil slices over zero-length slices (#19084)
parent
f1537b77
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
5 deletions
+5
-5
database.go
trie/database.go
+1
-1
proof.go
trie/proof.go
+1
-1
sync.go
trie/sync.go
+2
-2
sync_test.go
trie/sync_test.go
+1
-1
No files found.
trie/database.go
View file @
514a9472
...
@@ -809,7 +809,7 @@ func (db *Database) verifyIntegrity() {
...
@@ -809,7 +809,7 @@ func (db *Database) verifyIntegrity() {
db
.
accumulate
(
child
,
reachable
)
db
.
accumulate
(
child
,
reachable
)
}
}
// Find any unreachable but cached nodes
// Find any unreachable but cached nodes
unreachable
:=
[]
string
{}
var
unreachable
[]
string
for
hash
,
node
:=
range
db
.
dirties
{
for
hash
,
node
:=
range
db
.
dirties
{
if
_
,
ok
:=
reachable
[
hash
];
!
ok
{
if
_
,
ok
:=
reachable
[
hash
];
!
ok
{
unreachable
=
append
(
unreachable
,
fmt
.
Sprintf
(
"%x: {Node: %v, Parents: %d, Prev: %x, Next: %x}"
,
unreachable
=
append
(
unreachable
,
fmt
.
Sprintf
(
"%x: {Node: %v, Parents: %d, Prev: %x, Next: %x}"
,
...
...
trie/proof.go
View file @
514a9472
...
@@ -37,7 +37,7 @@ import (
...
@@ -37,7 +37,7 @@ import (
func
(
t
*
Trie
)
Prove
(
key
[]
byte
,
fromLevel
uint
,
proofDb
ethdb
.
Putter
)
error
{
func
(
t
*
Trie
)
Prove
(
key
[]
byte
,
fromLevel
uint
,
proofDb
ethdb
.
Putter
)
error
{
// Collect all nodes on the path to key.
// Collect all nodes on the path to key.
key
=
keybytesToHex
(
key
)
key
=
keybytesToHex
(
key
)
nodes
:=
[]
node
{}
var
nodes
[]
node
tn
:=
t
.
root
tn
:=
t
.
root
for
len
(
key
)
>
0
&&
tn
!=
nil
{
for
len
(
key
)
>
0
&&
tn
!=
nil
{
switch
n
:=
tn
.
(
type
)
{
switch
n
:=
tn
.
(
type
)
{
...
...
trie/sync.go
View file @
514a9472
...
@@ -157,7 +157,7 @@ func (s *Sync) AddRawEntry(hash common.Hash, depth int, parent common.Hash) {
...
@@ -157,7 +157,7 @@ func (s *Sync) AddRawEntry(hash common.Hash, depth int, parent common.Hash) {
// Missing retrieves the known missing nodes from the trie for retrieval.
// Missing retrieves the known missing nodes from the trie for retrieval.
func
(
s
*
Sync
)
Missing
(
max
int
)
[]
common
.
Hash
{
func
(
s
*
Sync
)
Missing
(
max
int
)
[]
common
.
Hash
{
requests
:=
[]
common
.
Hash
{}
var
requests
[]
common
.
Hash
for
!
s
.
queue
.
Empty
()
&&
(
max
==
0
||
len
(
requests
)
<
max
)
{
for
!
s
.
queue
.
Empty
()
&&
(
max
==
0
||
len
(
requests
)
<
max
)
{
requests
=
append
(
requests
,
s
.
queue
.
PopItem
()
.
(
common
.
Hash
))
requests
=
append
(
requests
,
s
.
queue
.
PopItem
()
.
(
common
.
Hash
))
}
}
...
@@ -254,7 +254,7 @@ func (s *Sync) children(req *request, object node) ([]*request, error) {
...
@@ -254,7 +254,7 @@ func (s *Sync) children(req *request, object node) ([]*request, error) {
node
node
node
node
depth
int
depth
int
}
}
children
:=
[]
child
{}
var
children
[]
child
switch
node
:=
(
object
)
.
(
type
)
{
switch
node
:=
(
object
)
.
(
type
)
{
case
*
shortNode
:
case
*
shortNode
:
...
...
trie/sync_test.go
View file @
514a9472
...
@@ -313,7 +313,7 @@ func TestIncompleteSync(t *testing.T) {
...
@@ -313,7 +313,7 @@ func TestIncompleteSync(t *testing.T) {
triedb
:=
NewDatabase
(
diskdb
)
triedb
:=
NewDatabase
(
diskdb
)
sched
:=
NewSync
(
srcTrie
.
Hash
(),
diskdb
,
nil
)
sched
:=
NewSync
(
srcTrie
.
Hash
(),
diskdb
,
nil
)
added
:=
[]
common
.
Hash
{}
var
added
[]
common
.
Hash
queue
:=
append
([]
common
.
Hash
{},
sched
.
Missing
(
1
)
...
)
queue
:=
append
([]
common
.
Hash
{},
sched
.
Missing
(
1
)
...
)
for
len
(
queue
)
>
0
{
for
len
(
queue
)
>
0
{
// Fetch a batch of trie nodes
// Fetch a batch of trie nodes
...
...
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