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):
507
507
logger .info (f'canonical_head={ canonical_head } ' )
508
508
509
509
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
+
510
516
if __name__ == "__main__" :
511
517
logging .basicConfig (
512
518
level = logging .DEBUG ,
@@ -594,6 +600,12 @@ def read_trinity(location):
594
600
)
595
601
read_geth_parser .add_argument ('-gethdb' , type = str , required = True )
596
602
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
+
597
609
args = parser .parse_args ()
598
610
599
611
if args .command == 'import_body_range' :
@@ -620,5 +632,8 @@ def read_trinity(location):
620
632
gethdb = open_gethdb (args .gethdb )
621
633
chain = open_trinitydb (args .destdb )
622
634
sweep_state (gethdb , chain .headerdb .db )
635
+ elif args .command == 'compact' :
636
+ chain = open_trinitydb (args .destdb )
637
+ compact (chain )
623
638
else :
624
639
logger .error (f'unrecognized command. command={ args .command } ' )
You can’t perform that action at this time.
0 commit comments