Merge pull request #2485 from karalabe/fakepow

cmd: add a `--fakepow` flag to help benchmarking database changes
This commit is contained in:
Péter Szilágyi 2016-04-29 14:19:38 +03:00
commit 9672a62a38
3 changed files with 16 additions and 5 deletions

View File

@ -206,6 +206,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.NetworkIdFlag,
utils.RPCCORSDomainFlag,
utils.MetricsEnabledFlag,
utils.FakePoWFlag,
utils.SolcPathFlag,
utils.GpoMinGasPriceFlag,
utils.GpoMaxGasPriceFlag,

View File

@ -151,7 +151,10 @@ var AppHelpFlagGroups = []flagGroup{
},
{
Name: "LOGGING AND DEBUGGING",
Flags: append([]cli.Flag{utils.MetricsEnabledFlag}, debug.Flags...),
Flags: append([]cli.Flag{
utils.MetricsEnabledFlag,
utils.FakePoWFlag,
}, debug.Flags...),
},
{
Name: "EXPERIMENTAL",

View File

@ -47,6 +47,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/whisper"
)
@ -228,6 +229,10 @@ var (
Name: metrics.MetricsEnabledFlag,
Usage: "Enable metrics collection and reporting",
}
FakePoWFlag = cli.BoolFlag{
Name: "fakepow",
Usage: "Disables proof-of-work verification",
}
// RPC settings
RPCEnabledFlag = cli.BoolFlag{
@ -842,11 +847,13 @@ func MakeChain(ctx *cli.Context) (chain *core.BlockChain, chainDb ethdb.Database
glog.Fatalln(err)
}
}
chainConfig := MustMakeChainConfigFromDb(ctx, chainDb)
var eventMux event.TypeMux
chain, err = core.NewBlockChain(chainDb, chainConfig, ethash.New(), &eventMux)
pow := pow.PoW(core.FakePow{})
if !ctx.GlobalBool(FakePoWFlag.Name) {
pow = ethash.New()
}
chain, err = core.NewBlockChain(chainDb, chainConfig, pow, new(event.TypeMux))
if err != nil {
Fatalf("Could not start chainmanager: %v", err)
}