|
|
@ -78,12 +78,12 @@ type Ethereum struct { |
|
|
|
|
|
|
|
|
|
|
|
miner *miner.Miner |
|
|
|
miner *miner.Miner |
|
|
|
gasPrice *big.Int |
|
|
|
gasPrice *big.Int |
|
|
|
Mining bool |
|
|
|
|
|
|
|
MinerThreads int |
|
|
|
|
|
|
|
etherbase common.Address |
|
|
|
etherbase common.Address |
|
|
|
|
|
|
|
|
|
|
|
networkId uint64 |
|
|
|
networkId uint64 |
|
|
|
netRPCService *ethapi.PublicNetAPI |
|
|
|
netRPCService *ethapi.PublicNetAPI |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (s *Ethereum) AddLesServer(ls LesServer) { |
|
|
|
func (s *Ethereum) AddLesServer(ls LesServer) { |
|
|
@ -121,8 +121,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { |
|
|
|
shutdownChan: make(chan bool), |
|
|
|
shutdownChan: make(chan bool), |
|
|
|
stopDbUpgrade: stopDbUpgrade, |
|
|
|
stopDbUpgrade: stopDbUpgrade, |
|
|
|
networkId: config.NetworkId, |
|
|
|
networkId: config.NetworkId, |
|
|
|
|
|
|
|
gasPrice: config.GasPrice, |
|
|
|
etherbase: config.Etherbase, |
|
|
|
etherbase: config.Etherbase, |
|
|
|
MinerThreads: config.MinerThreads, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := addMipmapBloomBins(chainDb); err != nil { |
|
|
|
if err := addMipmapBloomBins(chainDb); err != nil { |
|
|
@ -169,7 +169,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
eth.miner = miner.New(eth, eth.chainConfig, eth.EventMux(), eth.engine) |
|
|
|
eth.miner = miner.New(eth, eth.chainConfig, eth.EventMux(), eth.engine) |
|
|
|
eth.gasPrice = config.GasPrice |
|
|
|
|
|
|
|
eth.miner.SetExtra(makeExtraData(config.ExtraData)) |
|
|
|
eth.miner.SetExtra(makeExtraData(config.ExtraData)) |
|
|
|
|
|
|
|
|
|
|
|
eth.ApiBackend = &EthApiBackend{eth, nil} |
|
|
|
eth.ApiBackend = &EthApiBackend{eth, nil} |
|
|
@ -295,8 +294,12 @@ func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (s *Ethereum) Etherbase() (eb common.Address, err error) { |
|
|
|
func (s *Ethereum) Etherbase() (eb common.Address, err error) { |
|
|
|
if s.etherbase != (common.Address{}) { |
|
|
|
s.lock.RLock() |
|
|
|
return s.etherbase, nil |
|
|
|
etherbase := s.etherbase |
|
|
|
|
|
|
|
s.lock.RUnlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if etherbase != (common.Address{}) { |
|
|
|
|
|
|
|
return etherbase, nil |
|
|
|
} |
|
|
|
} |
|
|
|
if wallets := s.AccountManager().Wallets(); len(wallets) > 0 { |
|
|
|
if wallets := s.AccountManager().Wallets(); len(wallets) > 0 { |
|
|
|
if accounts := wallets[0].Accounts(); len(accounts) > 0 { |
|
|
|
if accounts := wallets[0].Accounts(); len(accounts) > 0 { |
|
|
@ -308,7 +311,10 @@ func (s *Ethereum) Etherbase() (eb common.Address, err error) { |
|
|
|
|
|
|
|
|
|
|
|
// set in js console via admin interface or wrapper from cli flags
|
|
|
|
// set in js console via admin interface or wrapper from cli flags
|
|
|
|
func (self *Ethereum) SetEtherbase(etherbase common.Address) { |
|
|
|
func (self *Ethereum) SetEtherbase(etherbase common.Address) { |
|
|
|
|
|
|
|
self.lock.Lock() |
|
|
|
self.etherbase = etherbase |
|
|
|
self.etherbase = etherbase |
|
|
|
|
|
|
|
self.lock.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
self.miner.SetEtherbase(etherbase) |
|
|
|
self.miner.SetEtherbase(etherbase) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|