diff --git a/trie/database.go b/trie/database.go index 4f984b010a..6d7a160654 100644 --- a/trie/database.go +++ b/trie/database.go @@ -233,7 +233,7 @@ func expandNode(hash hashNode, n node) node { return &shortNode{ Key: compactToHex(n.Key), Val: expandNode(nil, n.Val), - flags: NodeFlag{ + flags: nodeFlag{ hash: hash, }, } @@ -241,7 +241,7 @@ func expandNode(hash hashNode, n node) node { case rawFullNode: // Full nodes need child expansion node := &fullNode{ - flags: NodeFlag{ + flags: nodeFlag{ hash: hash, }, } diff --git a/trie/node.go b/trie/node.go index 2aa1dc3bfe..45184524c0 100644 --- a/trie/node.go +++ b/trie/node.go @@ -36,12 +36,12 @@ type node interface { type ( fullNode struct { Children [17]node // Actual trie Node data to encode/decode (needs custom encoder) - flags NodeFlag + flags nodeFlag } shortNode struct { Key []byte Val node - flags NodeFlag + flags nodeFlag } hashNode []byte valueNode []byte @@ -61,8 +61,8 @@ func (n *fullNode) EncodeRLP(w io.Writer) error { func (n *fullNode) copy() *fullNode { copy := *n; return © } func (n *shortNode) copy() *shortNode { copy := *n; return © } -// NodeFlag contains caching-related metadata about a Node. -type NodeFlag struct { +// nodeFlag contains caching-related metadata about a Node. +type nodeFlag struct { hash hashNode // cached hash of the Node (may be nil) dirty bool // whether the Node has changes that must be written to the database } @@ -133,7 +133,7 @@ func decodeShort(hash, elems []byte) (node, error) { if err != nil { return nil, err } - flag := NodeFlag{hash: hash} + flag := nodeFlag{hash: hash} key := compactToHex(kbuf) if hasTerm(key) { // value Node @@ -151,7 +151,7 @@ func decodeShort(hash, elems []byte) (node, error) { } func decodeFull(hash, elems []byte) (*fullNode, error) { - n := &fullNode{flags: NodeFlag{hash: hash}} + n := &fullNode{flags: nodeFlag{hash: hash}} for i := 0; i < 16; i++ { cld, rest, err := decodeRef(elems) if err != nil { diff --git a/trie/proof.go b/trie/proof.go index 28139bebf2..a12886cb35 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -236,7 +236,7 @@ findFork: if len(right)-pos < len(rn.Key) || !bytes.Equal(rn.Key, right[pos:pos+len(rn.Key)]) { return errors.New("invalid edge path") } - rn.flags = NodeFlag{dirty: true} + rn.flags = nodeFlag{dirty: true} // Special case, the non-existent proof points to the same path // as the existent proof, but the path of existent proof is longer. // In this case, the fork point is this shortnode. @@ -251,7 +251,7 @@ findFork: if rightnode == nil { return errors.New("invalid edge path") } - rn.flags = NodeFlag{dirty: true} + rn.flags = nodeFlag{dirty: true} if leftnode != rightnode { break findFork } @@ -305,12 +305,12 @@ func unset(parent node, child node, key []byte, pos int, removeLeft bool) error for i := 0; i < int(key[pos]); i++ { cld.Children[i] = nil } - cld.flags = NodeFlag{dirty: true} + cld.flags = nodeFlag{dirty: true} } else { for i := key[pos] + 1; i < 16; i++ { cld.Children[i] = nil } - cld.flags = NodeFlag{dirty: true} + cld.flags = nodeFlag{dirty: true} } return unset(cld, cld.Children[key[pos]], key, pos+1, removeLeft) case *shortNode: @@ -337,7 +337,7 @@ func unset(parent node, child node, key []byte, pos int, removeLeft bool) error fn.Children[key[pos-1]] = nil return nil } - cld.flags = NodeFlag{dirty: true} + cld.flags = nodeFlag{dirty: true} return unset(cld, cld.Val, key, pos+len(cld.Key), removeLeft) case nil: // If the Node is nil, it's a child of the fork point diff --git a/trie/trie.go b/trie/trie.go index 695b38c70d..ad5804e0f9 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -47,8 +47,8 @@ type Trie struct { } // newFlag returns the Cache flag value for a newly created Node. -func (t *Trie) newFlag() NodeFlag { - return NodeFlag{dirty: true} +func (t *Trie) newFlag() nodeFlag { + return nodeFlag{dirty: true} } // New creates a trie with an existing root Node from Db.