This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -507,6 +507,12 @@ def read_trinity(location):
507507 logger .info (f'canonical_head={ canonical_head } ' )
508508
509509
510+ def compact (chain ):
511+ logger .info ('this might take a while' )
512+ leveldb = chain .headerdb .db .db # what law of demeter?
513+ leveldb .compact_range ()
514+
515+
510516if __name__ == "__main__" :
511517 logging .basicConfig (
512518 level = logging .DEBUG ,
@@ -594,6 +600,12 @@ def read_trinity(location):
594600 )
595601 read_geth_parser .add_argument ('-gethdb' , type = str , required = True )
596602
603+ compact_parser = subparsers .add_parser (
604+ "compact" ,
605+ help = "Runs a compaction over the database, do this after importing state!" ,
606+ )
607+ compact_parser .add_argument ('-destdb' , type = str , required = True )
608+
597609 args = parser .parse_args ()
598610
599611 if args .command == 'import_body_range' :
@@ -620,5 +632,8 @@ def read_trinity(location):
620632 gethdb = open_gethdb (args .gethdb )
621633 chain = open_trinitydb (args .destdb )
622634 sweep_state (gethdb , chain .headerdb .db )
635+ elif args .command == 'compact' :
636+ chain = open_trinitydb (args .destdb )
637+ compact (chain )
623638 else :
624639 logger .error (f'unrecognized command. command={ args .command } ' )
You can’t perform that action at this time.
0 commit comments