Skip to content

Commit

Permalink
cmd/utils, eth, les: bubble --fakepow flag into eth/les too
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Jan 4, 2017
1 parent 891fcd8 commit 2ce3038
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
GpobaseCorrectionFactor: ctx.GlobalInt(GpobaseCorrectionFactorFlag.Name),
SolcPath: ctx.GlobalString(SolcPathFlag.Name),
AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name),
PowFake: ctx.GlobalBool(FakePoWFlag.Name),
}

// Override any default configs in dev mode or the test net
Expand Down
14 changes: 8 additions & 6 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/rpc"
)

Expand Down Expand Up @@ -79,6 +80,7 @@ type Config struct {
NatSpec bool
DocRoot string
AutoDAG bool
PowFake bool
PowTest bool
PowShared bool
ExtraData []byte
Expand Down Expand Up @@ -125,7 +127,7 @@ type Ethereum struct {
chainDb ethdb.Database // Block chain database

eventMux *event.TypeMux
pow *ethash.Ethash
pow pow.PoW
accountManager *accounts.Manager

ApiBackend *EthApiBackend
Expand All @@ -139,7 +141,6 @@ type Ethereum struct {
solcPath string

NatSpec bool
PowTest bool
netVersionId int
netRPCService *ethapi.PublicNetAPI
}
Expand Down Expand Up @@ -174,7 +175,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
stopDbUpgrade: stopDbUpgrade,
netVersionId: config.NetworkId,
NatSpec: config.NatSpec,
PowTest: config.PowTest,
etherbase: config.Etherbase,
MinerThreads: config.MinerThreads,
AutoDAG: config.AutoDAG,
Expand Down Expand Up @@ -293,15 +293,17 @@ func SetupGenesisBlock(chainDb *ethdb.Database, config *Config) error {
}

// CreatePoW creates the required type of PoW instance for an Ethereum service
func CreatePoW(config *Config) (*ethash.Ethash, error) {
func CreatePoW(config *Config) (pow.PoW, error) {
switch {
case config.PowFake:
glog.V(logger.Info).Infof("ethash used in fake mode")
return pow.PoW(core.FakePow{}), nil
case config.PowTest:
glog.V(logger.Info).Infof("ethash used in test mode")
return ethash.NewForTesting()
case config.PowShared:
glog.V(logger.Info).Infof("ethash used in shared mode")
return ethash.NewShared(), nil

default:
return ethash.New(), nil
}
Expand Down Expand Up @@ -399,7 +401,7 @@ func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager
func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
func (s *Ethereum) Pow() *ethash.Ethash { return s.pow }
func (s *Ethereum) Pow() pow.PoW { return s.pow }
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
func (s *Ethereum) IsListening() bool { return true } // Always listening
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
Expand Down
6 changes: 2 additions & 4 deletions les/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"time"

"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/compiler"
Expand All @@ -42,6 +41,7 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
rpc "github.com/ethereum/go-ethereum/rpc"
)

Expand All @@ -61,13 +61,12 @@ type LightEthereum struct {
ApiBackend *LesApiBackend

eventMux *event.TypeMux
pow *ethash.Ethash
pow pow.PoW
accountManager *accounts.Manager
solcPath string
solc *compiler.Solidity

NatSpec bool
PowTest bool
netVersionId int
netRPCService *ethapi.PublicNetAPI
}
Expand Down Expand Up @@ -97,7 +96,6 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
shutdownChan: make(chan bool),
netVersionId: config.NetworkId,
NatSpec: config.NatSpec,
PowTest: config.PowTest,
solcPath: config.SolcPath,
}

Expand Down

0 comments on commit 2ce3038

Please sign in to comment.