Skip to content

Commit

Permalink
cmd: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Mar 22, 2021
1 parent 987adaa commit c686af6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func importChain(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx)
defer stack.Close()

chain, db := utils.MakeChain(ctx, stack, false, false)
chain, db := utils.MakeChain(ctx, stack)
defer db.Close()

// Start periodically gathering memory profiles
Expand Down Expand Up @@ -304,7 +304,7 @@ func exportChain(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx)
defer stack.Close()

chain, _ := utils.MakeChain(ctx, stack, true, true)
chain, _ := utils.MakeChain(ctx, stack)
start := time.Now()

var err error
Expand Down Expand Up @@ -373,7 +373,7 @@ func dump(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx)
defer stack.Close()

chain, chainDb := utils.MakeChain(ctx, stack, true, true)
chain, chainDb := utils.MakeChain(ctx, stack)
defer chainDb.Close()
for _, arg := range ctx.Args() {
var block *types.Block
Expand Down
8 changes: 4 additions & 4 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func pruneState(ctx *cli.Context) error {
stack, config := makeConfigNode(ctx)
defer stack.Close()

chain, chaindb := utils.MakeChain(ctx, stack, true, false)
chain, chaindb := utils.MakeChain(ctx, stack)
defer chaindb.Close()

pruner, err := pruner.NewPruner(chaindb, chain.CurrentBlock().Header(), stack.ResolvePath(""), stack.ResolvePath(config.Eth.TrieCleanCacheJournal), ctx.GlobalUint64(utils.BloomFilterSizeFlag.Name))
Expand Down Expand Up @@ -183,7 +183,7 @@ func verifyState(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx)
defer stack.Close()

chain, chaindb := utils.MakeChain(ctx, stack, true, true)
chain, chaindb := utils.MakeChain(ctx, stack)
defer chaindb.Close()

snaptree, err := snapshot.New(chaindb, trie.NewDatabase(chaindb), 256, chain.CurrentBlock().Root(), false, false, false)
Expand Down Expand Up @@ -218,7 +218,7 @@ func traverseState(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx)
defer stack.Close()

chain, chaindb := utils.MakeChain(ctx, stack, true, true)
chain, chaindb := utils.MakeChain(ctx, stack)
defer chaindb.Close()

if ctx.NArg() > 1 {
Expand Down Expand Up @@ -311,7 +311,7 @@ func traverseRawState(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx)
defer stack.Close()

chain, chaindb := utils.MakeChain(ctx, stack, true, true)
chain, chaindb := utils.MakeChain(ctx, stack)
defer chaindb.Close()

if ctx.NArg() > 1 {
Expand Down
14 changes: 5 additions & 9 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1790,9 +1790,9 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
}

// MakeChain creates a chain manager from set command line flags.
func MakeChain(ctx *cli.Context, stack *node.Node, chainReadOnly bool, dbReadOnly bool) (chain *core.BlockChain, chainDb ethdb.Database) {
func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) {
var err error
chainDb = MakeChainDatabase(ctx, stack, dbReadOnly)
chainDb = MakeChainDatabase(ctx, stack, false) // TODO(rjl493456442) support read-only database
config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx))
if err != nil {
Fatalf("%v", err)
Expand Down Expand Up @@ -1842,13 +1842,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node, chainReadOnly bool, dbReadOnl
}
vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}

// TODO disable snapshot generation/wiping if the chain is read only.
var limit *uint64
if ctx.GlobalIsSet(TxLookupLimitFlag.Name) && !chainReadOnly {
l := ctx.GlobalUint64(TxLookupLimitFlag.Name)
limit = &l
}
chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, limit)
// TODO(rjl493456442) disable snapshot generation/wiping if the chain is read only.
// Disable transaction indexing/unindexing by default.
chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, nil)
if err != nil {
Fatalf("Can't create BlockChain: %v", err)
}
Expand Down

0 comments on commit c686af6

Please sign in to comment.