@@ -1632,6 +1632,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
1632
1632
if ctx .IsSet (CacheNoPrefetchFlag .Name ) {
1633
1633
cfg .NoPrefetch = ctx .Bool (CacheNoPrefetchFlag .Name )
1634
1634
}
1635
+ if ctx .IsSet (DataDirFlag .Name ) {
1636
+ chaindb := tryMakeReadOnlyDatabase (ctx , stack )
1637
+ scheme , err := rawdb .ParseStateScheme (ctx .String (StateSchemeFlag .Name ), chaindb )
1638
+ if err != nil {
1639
+ Fatalf ("%v" , err )
1640
+ }
1641
+ cfg .StateScheme = scheme
1642
+ chaindb .Close ()
1643
+ }
1635
1644
// Read the value from the flag no matter if it's set or not.
1636
1645
cfg .Preimages = ctx .Bool (CachePreimagesFlag .Name )
1637
1646
if cfg .NoPruning && ! cfg .Preimages {
@@ -1641,9 +1650,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
1641
1650
if ctx .IsSet (StateHistoryFlag .Name ) {
1642
1651
cfg .StateHistory = ctx .Uint64 (StateHistoryFlag .Name )
1643
1652
}
1644
- if ctx .IsSet (StateSchemeFlag .Name ) {
1645
- cfg .StateScheme = ctx .String (StateSchemeFlag .Name )
1646
- }
1647
1653
// Parse transaction history flag, if user is still using legacy config
1648
1654
// file with 'TxLookupLimit' configured, copy the value to 'TransactionHistory'.
1649
1655
if cfg .TransactionHistory == ethconfig .Defaults .TransactionHistory && cfg .TxLookupLimit != ethconfig .Defaults .TxLookupLimit {
@@ -1657,17 +1663,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
1657
1663
cfg .TransactionHistory = ctx .Uint64 (TxLookupLimitFlag .Name )
1658
1664
}
1659
1665
1660
- if ctx .String (GCModeFlag .Name ) == "archive" && cfg .TransactionHistory != 0 && ctx .IsSet (DataDirFlag .Name ) {
1661
- chaindb := tryMakeReadOnlyDatabase (ctx , stack )
1662
- scheme , err := rawdb .ParseStateScheme (cfg .StateScheme , chaindb )
1663
- if err != nil {
1664
- Fatalf ("%v" , err )
1665
- }
1666
- if scheme == rawdb .HashScheme {
1667
- cfg .TransactionHistory = 0
1668
- log .Warn ("Disabled transaction unindexing for archive node with hash state scheme" )
1669
- }
1670
- chaindb .Close ()
1666
+ if ctx .String (GCModeFlag .Name ) == "archive" && cfg .TransactionHistory != 0 && cfg .StateScheme == rawdb .HashScheme {
1667
+ cfg .TransactionHistory = 0
1668
+ log .Warn ("Disabled transaction unindexing for archive node with hash state scheme" )
1671
1669
}
1672
1670
if ctx .IsSet (LogHistoryFlag .Name ) {
1673
1671
cfg .LogHistory = ctx .Uint64 (LogHistoryFlag .Name )
@@ -2206,9 +2204,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
2206
2204
// Disable transaction indexing/unindexing.
2207
2205
TxLookupLimit : - 1 ,
2208
2206
}
2209
- if options .ArchiveMode && ! options .Preimages {
2207
+ if options .ArchiveMode && ! options .Preimages && scheme == rawdb . HashScheme {
2210
2208
options .Preimages = true
2211
- log .Info ("Enabling recording of key preimages since archive mode is used" )
2209
+ log .Info ("Enabling recording of key preimages since archive mode is used in hash state scheme " )
2212
2210
}
2213
2211
if ! ctx .Bool (SnapshotFlag .Name ) {
2214
2212
options .SnapshotLimit = 0 // Disabled
0 commit comments