@@ -97,18 +97,16 @@ type Database struct {
9797// in the same cache fields).
9898type rawNode []byte
9999
100- func (n rawNode ) canUnload (uint16 , uint16 ) bool { panic ("this should never end up in a live trie" ) }
101- func (n rawNode ) cache () (hashNode , bool ) { panic ("this should never end up in a live trie" ) }
102- func (n rawNode ) fstring (ind string ) string { panic ("this should never end up in a live trie" ) }
100+ func (n rawNode ) cache () (hashNode , bool ) { panic ("this should never end up in a live trie" ) }
101+ func (n rawNode ) fstring (ind string ) string { panic ("this should never end up in a live trie" ) }
103102
104103// rawFullNode represents only the useful data content of a full node, with the
105104// caches and flags stripped out to minimize its data storage. This type honors
106105// the same RLP encoding as the original parent.
107106type rawFullNode [17 ]node
108107
109- func (n rawFullNode ) canUnload (uint16 , uint16 ) bool { panic ("this should never end up in a live trie" ) }
110- func (n rawFullNode ) cache () (hashNode , bool ) { panic ("this should never end up in a live trie" ) }
111- func (n rawFullNode ) fstring (ind string ) string { panic ("this should never end up in a live trie" ) }
108+ func (n rawFullNode ) cache () (hashNode , bool ) { panic ("this should never end up in a live trie" ) }
109+ func (n rawFullNode ) fstring (ind string ) string { panic ("this should never end up in a live trie" ) }
112110
113111func (n rawFullNode ) EncodeRLP (w io.Writer ) error {
114112 var nodes [17 ]node
@@ -131,9 +129,8 @@ type rawShortNode struct {
131129 Val node
132130}
133131
134- func (n rawShortNode ) canUnload (uint16 , uint16 ) bool { panic ("this should never end up in a live trie" ) }
135- func (n rawShortNode ) cache () (hashNode , bool ) { panic ("this should never end up in a live trie" ) }
136- func (n rawShortNode ) fstring (ind string ) string { panic ("this should never end up in a live trie" ) }
132+ func (n rawShortNode ) cache () (hashNode , bool ) { panic ("this should never end up in a live trie" ) }
133+ func (n rawShortNode ) fstring (ind string ) string { panic ("this should never end up in a live trie" ) }
137134
138135// cachedNode is all the information we know about a single cached node in the
139136// memory database write layer.
@@ -841,7 +838,7 @@ func (c *cleaner) Put(key []byte, rlp []byte) error {
841838}
842839
843840func (c * cleaner ) Delete (key []byte ) error {
844- panic ("Not implemented" )
841+ panic ("not implemented" )
845842}
846843
847844// Size returns the current storage size of the memory cache in front of the
@@ -857,45 +854,3 @@ func (db *Database) Size() (common.StorageSize, common.StorageSize) {
857854 var metarootRefs = common .StorageSize (len (db .dirties [common.Hash {}].children ) * (common .HashLength + 2 ))
858855 return db .dirtiesSize + db .childrenSize + metadataSize - metarootRefs , db .preimagesSize
859856}
860-
861- // verifyIntegrity is a debug method to iterate over the entire trie stored in
862- // memory and check whether every node is reachable from the meta root. The goal
863- // is to find any errors that might cause memory leaks and or trie nodes to go
864- // missing.
865- //
866- // This method is extremely CPU and memory intensive, only use when must.
867- func (db * Database ) verifyIntegrity () {
868- // Iterate over all the cached nodes and accumulate them into a set
869- reachable := map [common.Hash ]struct {}{{}: {}}
870-
871- for child := range db .dirties [common.Hash {}].children {
872- db .accumulate (child , reachable )
873- }
874- // Find any unreachable but cached nodes
875- var unreachable []string
876- for hash , node := range db .dirties {
877- if _ , ok := reachable [hash ]; ! ok {
878- unreachable = append (unreachable , fmt .Sprintf ("%x: {Node: %v, Parents: %d, Prev: %x, Next: %x}" ,
879- hash , node .node , node .parents , node .flushPrev , node .flushNext ))
880- }
881- }
882- if len (unreachable ) != 0 {
883- panic (fmt .Sprintf ("trie cache memory leak: %v" , unreachable ))
884- }
885- }
886-
887- // accumulate iterates over the trie defined by hash and accumulates all the
888- // cached children found in memory.
889- func (db * Database ) accumulate (hash common.Hash , reachable map [common.Hash ]struct {}) {
890- // Mark the node reachable if present in the memory cache
891- node , ok := db .dirties [hash ]
892- if ! ok {
893- return
894- }
895- reachable [hash ] = struct {}{}
896-
897- // Iterate over all the children and accumulate them too
898- for _ , child := range node .childs () {
899- db .accumulate (child , reachable )
900- }
901- }
0 commit comments