trie: quell linter in commiter.go (#21329)

This commit is contained in:
Guillaume Ballet 2020-07-15 10:00:04 +02:00 committed by GitHub
parent 6c9f040ebe
commit 240d1851db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,20 +105,19 @@ func (c *committer) commit(n node, db *Database, force bool) (node, error) {
// Commit child
collapsed := cn.copy()
if _, ok := cn.Val.(valueNode); !ok {
if childV, err := c.commit(cn.Val, db, false); err != nil {
childV, err := c.commit(cn.Val, db, false)
if err != nil {
return nil, err
} else {
collapsed.Val = childV
}
collapsed.Val = childV
}
// The key needs to be copied, since we're delivering it to database
collapsed.Key = hexToCompact(cn.Key)
hashedNode := c.store(collapsed, db, force, true)
if hn, ok := hashedNode.(hashNode); ok {
return hn, nil
} else {
return collapsed, nil
}
return collapsed, nil
case *fullNode:
hashedKids, hasVnodes, err := c.commitChildren(cn, db, force)
if err != nil {
@ -130,9 +129,8 @@ func (c *committer) commit(n node, db *Database, force bool) (node, error) {
hashedNode := c.store(collapsed, db, force, hasVnodes)
if hn, ok := hashedNode.(hashNode); ok {
return hn, nil
} else {
return collapsed, nil
}
return collapsed, nil
case valueNode:
return c.store(cn, db, force, false), nil
// hashnodes aren't stored
@ -265,7 +263,7 @@ func estimateSize(n node) int {
if child := n.Children[i]; child != nil {
s += estimateSize(child)
} else {
s += 1
s++
}
}
return s