aboutsummaryrefslogtreecommitdiffstats
path: root/trie
diff options
context:
space:
mode:
authorMatthew Halpern <matthalp@google.com>2019-02-19 21:50:11 +0800
committerFelix Lange <fjl@users.noreply.github.com>2019-02-19 21:50:11 +0800
commit514a9472ad32b98897f1f4a7391eb21ac05aa609 (patch)
treef0d81305c89a9ce0193905309aa4022c03276548 /trie
parentf1537b774ce532844ec75e4cb4e0bd813cd7b4af (diff)
downloadgo-tangerine-514a9472ad32b98897f1f4a7391eb21ac05aa609.tar
go-tangerine-514a9472ad32b98897f1f4a7391eb21ac05aa609.tar.gz
go-tangerine-514a9472ad32b98897f1f4a7391eb21ac05aa609.tar.bz2
go-tangerine-514a9472ad32b98897f1f4a7391eb21ac05aa609.tar.lz
go-tangerine-514a9472ad32b98897f1f4a7391eb21ac05aa609.tar.xz
go-tangerine-514a9472ad32b98897f1f4a7391eb21ac05aa609.tar.zst
go-tangerine-514a9472ad32b98897f1f4a7391eb21ac05aa609.zip
trie: prefer nil slices over zero-length slices (#19084)
Diffstat (limited to 'trie')
-rw-r--r--trie/database.go2
-rw-r--r--trie/proof.go2
-rw-r--r--trie/sync.go4
-rw-r--r--trie/sync_test.go2
4 files changed, 5 insertions, 5 deletions
diff --git a/trie/database.go b/trie/database.go
index aba5943f5..958823eb8 100644
--- a/trie/database.go
+++ b/trie/database.go
@@ -809,7 +809,7 @@ func (db *Database) verifyIntegrity() {
db.accumulate(child, reachable)
}
// Find any unreachable but cached nodes
- unreachable := []string{}
+ var unreachable []string
for hash, node := range db.dirties {
if _, ok := reachable[hash]; !ok {
unreachable = append(unreachable, fmt.Sprintf("%x: {Node: %v, Parents: %d, Prev: %x, Next: %x}",
diff --git a/trie/proof.go b/trie/proof.go
index f90ecd7d8..1334bde97 100644
--- a/trie/proof.go
+++ b/trie/proof.go
@@ -37,7 +37,7 @@ import (
func (t *Trie) Prove(key []byte, fromLevel uint, proofDb ethdb.Putter) error {
// Collect all nodes on the path to key.
key = keybytesToHex(key)
- nodes := []node{}
+ var nodes []node
tn := t.root
for len(key) > 0 && tn != nil {
switch n := tn.(type) {
diff --git a/trie/sync.go b/trie/sync.go
index 67dff5a8b..44f5087b9 100644
--- a/trie/sync.go
+++ b/trie/sync.go
@@ -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.
func (s *Sync) Missing(max int) []common.Hash {
- requests := []common.Hash{}
+ var requests []common.Hash
for !s.queue.Empty() && (max == 0 || len(requests) < max) {
requests = append(requests, s.queue.PopItem().(common.Hash))
}
@@ -254,7 +254,7 @@ func (s *Sync) children(req *request, object node) ([]*request, error) {
node node
depth int
}
- children := []child{}
+ var children []child
switch node := (object).(type) {
case *shortNode:
diff --git a/trie/sync_test.go b/trie/sync_test.go
index c76779e5c..ff15baa52 100644
--- a/trie/sync_test.go
+++ b/trie/sync_test.go
@@ -313,7 +313,7 @@ func TestIncompleteSync(t *testing.T) {
triedb := NewDatabase(diskdb)
sched := NewSync(srcTrie.Hash(), diskdb, nil)
- added := []common.Hash{}
+ var added []common.Hash
queue := append([]common.Hash{}, sched.Missing(1)...)
for len(queue) > 0 {
// Fetch a batch of trie nodes