aboutsummaryrefslogtreecommitdiffstats
path: root/miner/worker.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-03-02 06:32:43 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2016-04-01 07:01:10 +0800
commitf0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c (patch)
tree02e31a0e31040980e30e3a835ff9eba73e419439 /miner/worker.go
parent10d3466c934bd425a8c941270749a652a588527d (diff)
downloadgo-tangerine-f0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c.tar.gz
go-tangerine-f0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c.tar.zst
go-tangerine-f0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c.zip
core: added basic chain configuration
Added chain configuration options and write out during genesis database insertion. If no "config" was found, nothing is written to the database. Configurations are written on a per genesis base. This means that any chain (which is identified by it's genesis hash) can have their own chain settings.
Diffstat (limited to 'miner/worker.go')
-rw-r--r--miner/worker.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/miner/worker.go b/miner/worker.go
index b3ddf9707..c45945b87 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -61,6 +61,7 @@ type uint64RingBuffer struct {
// environment is the workers current environment and holds
// all of the current state information
type Work struct {
+ config *core.ChainConfig
state *state.StateDB // apply state changes here
ancestors *set.Set // ancestor set (used for checking uncle parent validity)
family *set.Set // family set (used for checking uncle invalidity)
@@ -89,6 +90,8 @@ type Result struct {
// worker is the main object which takes care of applying messages to the new state
type worker struct {
+ config *core.ChainConfig
+
mu sync.Mutex
agents map[Agent]struct{}
@@ -122,8 +125,9 @@ type worker struct {
fullValidation bool
}
-func newWorker(coinbase common.Address, eth core.Backend) *worker {
+func newWorker(config *core.ChainConfig, coinbase common.Address, eth core.Backend) *worker {
worker := &worker{
+ config: config,
eth: eth,
mux: eth.EventMux(),
chainDb: eth.ChainDb(),
@@ -285,7 +289,7 @@ func (self *worker) wait() {
}
auxValidator := self.eth.BlockChain().AuxValidator()
- if err := core.ValidateHeader(auxValidator, block.Header(), parent.Header(), true, false); err != nil && err != core.BlockFutureErr {
+ if err := core.ValidateHeader(self.config, auxValidator, block.Header(), parent.Header(), true, false); err != nil && err != core.BlockFutureErr {
glog.V(logger.Error).Infoln("Invalid header on mined block:", err)
continue
}
@@ -371,6 +375,7 @@ func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error
return err
}
work := &Work{
+ config: self.config,
state: state,
ancestors: set.New(),
family: set.New(),
@@ -470,7 +475,7 @@ func (self *worker) commitNewWork() {
header := &types.Header{
ParentHash: parent.Hash(),
Number: num.Add(num, common.Big1),
- Difficulty: core.CalcDifficulty(uint64(tstamp), parent.Time().Uint64(), parent.Number(), parent.Difficulty()),
+ Difficulty: core.CalcDifficulty(self.config, uint64(tstamp), parent.Time().Uint64(), parent.Number(), parent.Difficulty()),
GasLimit: core.CalcGasLimit(parent),
GasUsed: new(big.Int),
Coinbase: self.coinbase,
@@ -657,7 +662,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, transactions types.Trans
func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) (error, vm.Logs) {
snap := env.state.Copy()
- receipt, logs, _, err := core.ApplyTransaction(bc, gp, env.state, env.header, tx, env.header.GasUsed, nil)
+ receipt, logs, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, env.config.VmConfig)
if err != nil {
env.state.Set(snap)
return err, nil