aboutsummaryrefslogtreecommitdiff
path: root/eth
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-08-14 01:37:25 -0400
committerDeterminant <ted.sybil@gmail.com>2019-08-14 01:37:25 -0400
commit592f21f5b97e5b1e714f194ae90ab83e6547cf41 (patch)
treec500cdf4ca4266af15703eca182df34d66715918 /eth
parentad886faec521f1edcb90f6f8eb4555608d085312 (diff)
finish a full chain example (with p2p network)
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go19
-rw-r--r--eth/config.go32
2 files changed, 47 insertions, 4 deletions
diff --git a/eth/backend.go b/eth/backend.go
index b5f590e..12041de 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -409,6 +409,17 @@ 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
@@ -509,10 +520,10 @@ func (s *Ethereum) Stop() error {
s.bloomIndexer.Close()
s.blockchain.Stop()
s.engine.Close()
- //s.protocolManager.Stop()
- //if s.lesServer != nil {
- // s.lesServer.Stop()
- //}
+ s.protocolManager.Stop()
+ if s.lesServer != nil {
+ s.lesServer.Stop()
+ }
s.txPool.Stop()
s.miner.Stop()
s.eventMux.Stop()
diff --git a/eth/config.go b/eth/config.go
index 6887872..3149c6f 100644
--- a/eth/config.go
+++ b/eth/config.go
@@ -24,6 +24,7 @@ import (
"runtime"
"time"
+ "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
@@ -155,3 +156,34 @@ type Config struct {
// CheckpointOracle is the configuration for checkpoint oracle.
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
}
+
+func MyDefaultConfig() Config {
+ config := DefaultConfig
+ chainConfig := &params.ChainConfig {
+ ChainID: big.NewInt(42222),
+ HomesteadBlock: big.NewInt(0),
+ DAOForkBlock: big.NewInt(0),
+ DAOForkSupport: true,
+ EIP150Block: big.NewInt(0),
+ EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
+ EIP155Block: big.NewInt(0),
+ EIP158Block: big.NewInt(0),
+ ByzantiumBlock: big.NewInt(0),
+ ConstantinopleBlock: big.NewInt(0),
+ PetersburgBlock: big.NewInt(0),
+ IstanbulBlock: nil,
+ Ethash: nil,
+ }
+ genBalance := big.NewInt(1000000000000000000)
+
+ config.Genesis = &core.Genesis{
+ Config: chainConfig,
+ Nonce: 0,
+ Number: 0,
+ ExtraData: hexutil.MustDecode("0x00"),
+ GasLimit: 100000000,
+ Difficulty: big.NewInt(0),
+ Alloc: core.GenesisAlloc{ common.Address{}: { Balance: genBalance }},
+ }
+ return config
+}