@@ -179,17 +179,18 @@ func InspectDatabase(db ethdb.Database) error {
179179 logged = time .Now ()
180180
181181 // Key-value store statistics
182- total common.StorageSize
183- headerSize common.StorageSize
184- bodySize common.StorageSize
185- receiptSize common.StorageSize
186- tdSize common.StorageSize
187- numHashPairing common.StorageSize
188- hashNumPairing common.StorageSize
189- trieSize common.StorageSize
190- txlookupSize common.StorageSize
191- preimageSize common.StorageSize
192- bloomBitsSize common.StorageSize
182+ total common.StorageSize
183+ headerSize common.StorageSize
184+ bodySize common.StorageSize
185+ receiptSize common.StorageSize
186+ tdSize common.StorageSize
187+ numHashPairing common.StorageSize
188+ hashNumPairing common.StorageSize
189+ trieSize common.StorageSize
190+ txlookupSize common.StorageSize
191+ preimageSize common.StorageSize
192+ bloomBitsSize common.StorageSize
193+ cliqueSnapsSize common.StorageSize
193194
194195 // Ancient store statistics
195196 ancientHeaders common.StorageSize
@@ -199,8 +200,12 @@ func InspectDatabase(db ethdb.Database) error {
199200 ancientTds common.StorageSize
200201
201202 // Les statistic
202- ChtTrieNodes common.StorageSize
203- BloomTrieNodes common.StorageSize
203+ chtTrieNodes common.StorageSize
204+ bloomTrieNodes common.StorageSize
205+
206+ // Meta- and unaccounted data
207+ metadata common.StorageSize
208+ unaccounted common.StorageSize
204209 )
205210 // Inspect key-value database first.
206211 for it .Next () {
@@ -228,12 +233,26 @@ func InspectDatabase(db ethdb.Database) error {
228233 preimageSize += size
229234 case bytes .HasPrefix (key , bloomBitsPrefix ) && len (key ) == (len (bloomBitsPrefix )+ 10 + common .HashLength ):
230235 bloomBitsSize += size
236+ case bytes .HasPrefix (key , []byte ("clique-" )) && len (key ) == 7 + common .HashLength :
237+ cliqueSnapsSize += size
231238 case bytes .HasPrefix (key , []byte ("cht-" )) && len (key ) == 4 + common .HashLength :
232- ChtTrieNodes += size
239+ chtTrieNodes += size
233240 case bytes .HasPrefix (key , []byte ("blt-" )) && len (key ) == 4 + common .HashLength :
234- BloomTrieNodes += size
241+ bloomTrieNodes += size
235242 case len (key ) == common .HashLength :
236243 trieSize += size
244+ default :
245+ var accounted bool
246+ for _ , meta := range [][]byte {databaseVerisionKey , headHeaderKey , headBlockKey , headFastBlockKey , fastTrieProgressKey , ancientKey } {
247+ if bytes .Equal (key , meta ) {
248+ metadata += size
249+ accounted = true
250+ break
251+ }
252+ }
253+ if ! accounted {
254+ unaccounted += size
255+ }
237256 }
238257 count += 1
239258 if count % 1000 == 0 && time .Since (logged ) > 8 * time .Second {
@@ -261,18 +280,24 @@ func InspectDatabase(db ethdb.Database) error {
261280 {"Key-Value store" , "Bloombit index" , bloomBitsSize .String ()},
262281 {"Key-Value store" , "Trie nodes" , trieSize .String ()},
263282 {"Key-Value store" , "Trie preimages" , preimageSize .String ()},
283+ {"Key-Value store" , "Clique snapshots" , cliqueSnapsSize .String ()},
284+ {"Key-Value store" , "Singleton metadata" , metadata .String ()},
264285 {"Ancient store" , "Headers" , ancientHeaders .String ()},
265286 {"Ancient store" , "Bodies" , ancientBodies .String ()},
266287 {"Ancient store" , "Receipts" , ancientReceipts .String ()},
267288 {"Ancient store" , "Difficulties" , ancientTds .String ()},
268289 {"Ancient store" , "Block number->hash" , ancientHashes .String ()},
269- {"Light client" , "CHT trie nodes" , ChtTrieNodes .String ()},
270- {"Light client" , "Bloom trie nodes" , BloomTrieNodes .String ()},
290+ {"Light client" , "CHT trie nodes" , chtTrieNodes .String ()},
291+ {"Light client" , "Bloom trie nodes" , bloomTrieNodes .String ()},
271292 }
272293 table := tablewriter .NewWriter (os .Stdout )
273294 table .SetHeader ([]string {"Database" , "Category" , "Size" })
274295 table .SetFooter ([]string {"" , "Total" , total .String ()})
275296 table .AppendBulk (stats )
276297 table .Render ()
298+
299+ if unaccounted > 0 {
300+ log .Error ("Database contains unaccounted data" , "size" , unaccounted )
301+ }
277302 return nil
278303}
0 commit comments