From bc9539a1b60dc80946bc867681eb32ecae4f0d66 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 12 Aug 2019 18:10:03 -0400 Subject: make the basic demo work --- eth/backend.go | 50 +++----------------------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) (limited to 'eth') diff --git a/eth/backend.go b/eth/backend.go index 048074d..dd91405 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -34,6 +34,7 @@ import ( "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" mycore "github.com/Determinant/coreth/core" + "github.com/Determinant/coreth/consensus/dummy" "github.com/ethereum/go-ethereum/core/bloombits" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" @@ -45,7 +46,7 @@ import ( "github.com/ethereum/go-ethereum/event" "github.com/Determinant/coreth/internal/ethapi" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/miner" + "github.com/Determinant/coreth/miner" "github.com/Determinant/coreth/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/enr" @@ -245,33 +246,7 @@ func makeExtraData(extra []byte) []byte { // CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine { - // If proof-of-authority is requested, set it up - if chainConfig.Clique != nil { - return clique.New(chainConfig.Clique, db) - } - // Otherwise assume proof-of-work - switch config.PowMode { - case ethash.ModeFake: - log.Warn("Ethash used in fake mode") - return ethash.NewFaker() - case ethash.ModeTest: - log.Warn("Ethash used in test mode") - return ethash.NewTester(nil, noverify) - case ethash.ModeShared: - log.Warn("Ethash used in shared mode") - return ethash.NewShared() - default: - engine := ethash.New(ethash.Config{ - CacheDir: ctx.ResolvePath(config.CacheDir), - CachesInMem: config.CachesInMem, - CachesOnDisk: config.CachesOnDisk, - DatasetDir: config.DatasetDir, - DatasetsInMem: config.DatasetsInMem, - DatasetsOnDisk: config.DatasetsOnDisk, - }, notify, noverify) - engine.SetThreads(-1) // Disable CPU mining - return engine - } + return new(dummy.DummyEngine) } // APIs return the collection of RPC services the ethereum package offers. @@ -434,17 +409,6 @@ func (s *Ethereum) SetEtherbase(etherbase common.Address) { // is already running, this method adjust the number of threads allowed to use // and updates the minimum price required by the transaction pool. func (s *Ethereum) StartMining(threads int) error { - // Update the thread count within the consensus engine - type threaded interface { - SetThreads(threads int) - } - if th, ok := s.engine.(threaded); ok { - log.Info("Updated mining threads", "threads", threads) - if threads == 0 { - threads = -1 // Disable the miner from within - } - th.SetThreads(threads) - } // If the miner was not running, initialize it if !s.IsMining() { // Propagate the initial price point to the transaction pool @@ -459,14 +423,6 @@ func (s *Ethereum) StartMining(threads int) error { log.Error("Cannot start mining without etherbase", "err", err) return fmt.Errorf("etherbase missing: %v", err) } - if clique, ok := s.engine.(*clique.Clique); ok { - wallet, err := s.accountManager.Find(accounts.Account{Address: eb}) - if wallet == nil || err != nil { - log.Error("Etherbase account unavailable locally", "err", err) - return fmt.Errorf("signer missing: %v", err) - } - clique.Authorize(eb, wallet.SignData) - } // If mining is started, we can disable the transaction rejection mechanism // introduced to speed sync times. atomic.StoreUint32(&s.protocolManager.acceptTxs, 1) -- cgit v1.2.3-70-g09d2