@@ -180,40 +180,6 @@ func (n *cachedNode) obj(hash common.Hash) node {
180180 return expandNode (hash [:], n .node )
181181}
182182
183- // childs returns all the tracked children of this node, both the implicit ones
184- // from inside the node as well as the explicit ones from outside the node.
185- func (n * cachedNode ) childs () []common.Hash {
186- children := make ([]common.Hash , 0 , 16 )
187- for child := range n .children {
188- children = append (children , child )
189- }
190- if _ , ok := n .node .(rawNode ); ! ok {
191- gatherChildren (n .node , & children )
192- }
193- return children
194- }
195-
196- // gatherChildren traverses the node hierarchy of a collapsed storage node and
197- // retrieves all the hashnode children.
198- func gatherChildren (n node , children * []common.Hash ) {
199- switch n := n .(type ) {
200- case * rawShortNode :
201- gatherChildren (n .Val , children )
202-
203- case rawFullNode :
204- for i := 0 ; i < 16 ; i ++ {
205- gatherChildren (n [i ], children )
206- }
207- case hashNode :
208- * children = append (* children , common .BytesToHash (n ))
209-
210- case valueNode , nil :
211-
212- default :
213- panic (fmt .Sprintf ("unknown node type: %T" , n ))
214- }
215- }
216-
217183// forChilds invokes the callback for all the tracked children of this node,
218184// both the implicit ones from inside the node as well as the explicit ones
219185//from outside the node.
@@ -796,10 +762,14 @@ func (db *Database) commit(hash common.Hash, batch ethdb.Batch, uncacher *cleane
796762 if ! ok {
797763 return nil
798764 }
799- for _ , child := range node .childs () {
800- if err := db .commit (child , batch , uncacher ); err != nil {
801- return err
765+ var err error
766+ node .forChilds (func (child common.Hash ) {
767+ if err == nil {
768+ err = db .commit (child , batch , uncacher )
802769 }
770+ })
771+ if err != nil {
772+ return err
803773 }
804774 if err := batch .Put (hash [:], node .rlp ()); err != nil {
805775 return err
0 commit comments