diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-04-05 06:16:29 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-04-05 06:16:29 +0800 |
commit | 09777952ee476ff80d4b6e63b5041ff5ca0e441b (patch) | |
tree | e85320f88f548201e3476b3e7095e96fd071617b /cmd | |
parent | e50a5b77712d891ff409aa942a5cbc24e721b332 (diff) | |
download | go-tangerine-09777952ee476ff80d4b6e63b5041ff5ca0e441b.tar go-tangerine-09777952ee476ff80d4b6e63b5041ff5ca0e441b.tar.gz go-tangerine-09777952ee476ff80d4b6e63b5041ff5ca0e441b.tar.bz2 go-tangerine-09777952ee476ff80d4b6e63b5041ff5ca0e441b.tar.lz go-tangerine-09777952ee476ff80d4b6e63b5041ff5ca0e441b.tar.xz go-tangerine-09777952ee476ff80d4b6e63b5041ff5ca0e441b.tar.zst go-tangerine-09777952ee476ff80d4b6e63b5041ff5ca0e441b.zip |
core, consensus: pluggable consensus engines (#3817)
This commit adds pluggable consensus engines to go-ethereum. In short, it
introduces a generic consensus interface, and refactors the entire codebase to
use this interface.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/evm/disasm.go | 2 | ||||
-rw-r--r-- | cmd/geth/main.go | 10 | ||||
-rw-r--r-- | cmd/geth/misccmd.go | 4 | ||||
-rw-r--r-- | cmd/utils/flags.go | 10 |
4 files changed, 17 insertions, 9 deletions
diff --git a/cmd/evm/disasm.go b/cmd/evm/disasm.go index 01a8c60ba..a78b2a8e1 100644 --- a/cmd/evm/disasm.go +++ b/cmd/evm/disasm.go @@ -20,10 +20,10 @@ import ( "errors" "fmt" "io/ioutil" + "strings" "github.com/ethereum/go-ethereum/core/asm" cli "gopkg.in/urfave/cli.v1" - "strings" ) var disasmCommand = cli.Command{ diff --git a/cmd/geth/main.go b/cmd/geth/main.go index cc6d3ac6a..e942d53c8 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -303,7 +303,15 @@ func startNode(ctx *cli.Context, stack *node.Node) { if err := stack.Service(ðereum); err != nil { utils.Fatalf("ethereum service not running: %v", err) } - if err := ethereum.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name)); err != nil { + if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 { + type threaded interface { + SetThreads(threads int) + } + if th, ok := ethereum.Engine().(threaded); ok { + th.SetThreads(threads) + } + } + if err := ethereum.StartMining(); err != nil { utils.Fatalf("Failed to start mining: %v", err) } } diff --git a/cmd/geth/misccmd.go b/cmd/geth/misccmd.go index 073c36beb..079f49310 100644 --- a/cmd/geth/misccmd.go +++ b/cmd/geth/misccmd.go @@ -26,9 +26,9 @@ import ( "strings" "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/pow" "gopkg.in/urfave/cli.v1" ) @@ -87,7 +87,7 @@ func makedag(ctx *cli.Context) error { utils.Fatalf("Can't find dir") } fmt.Println("making DAG, this could take awhile...") - pow.MakeDataset(blockNum, dir) + ethash.MakeDataset(blockNum, dir) } default: wrongArgs() diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 478e08834..acdf5d5dc 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -32,6 +32,7 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" @@ -49,7 +50,6 @@ import ( "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/p2p/netutil" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/pow" "github.com/ethereum/go-ethereum/rpc" whisper "github.com/ethereum/go-ethereum/whisper/whisperv2" "gopkg.in/urfave/cli.v1" @@ -149,7 +149,7 @@ var ( } TestNetFlag = cli.BoolFlag{ Name: "testnet", - Usage: "Ropsten network: pre-configured test network", + Usage: "Ropsten network: pre-configured proof-of-work test network", } DevModeFlag = cli.BoolFlag{ Name: "dev", @@ -921,16 +921,16 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai var err error chainDb = MakeChainDatabase(ctx, stack) - seal := pow.PoW(pow.FakePow{}) + engine := ethash.NewFaker() if !ctx.GlobalBool(FakePoWFlag.Name) { - seal = pow.NewFullEthash("", 1, 0, "", 1, 0) + engine = ethash.New("", 1, 0, "", 1, 0) } config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx)) if err != nil { Fatalf("%v", err) } vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)} - chain, err = core.NewBlockChain(chainDb, config, seal, new(event.TypeMux), vmcfg) + chain, err = core.NewBlockChain(chainDb, config, engine, new(event.TypeMux), vmcfg) if err != nil { Fatalf("Can't create BlockChain: %v", err) } |