mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
trie: rename NodeFlag to nodeFlag (#1049)
This commit is contained in:
parent
5dd41a6765
commit
5b071d1b0d
4 changed files with 15 additions and 15 deletions
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
12
trie/node.go
12
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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue