aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-05-29 15:21:34 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-05-29 15:21:34 +0800
commitc2a494c743e6fd32c5f14415d028432b051f8ea1 (patch)
tree417eca52de4c0cdb6a0c76afb54105a4c462d7e4 /eth/backend.go
parentcb809c03da18bf45f961a931dfd4c765de144e66 (diff)
downloaddexon-c2a494c743e6fd32c5f14415d028432b051f8ea1.tar
dexon-c2a494c743e6fd32c5f14415d028432b051f8ea1.tar.gz
dexon-c2a494c743e6fd32c5f14415d028432b051f8ea1.tar.bz2
dexon-c2a494c743e6fd32c5f14415d028432b051f8ea1.tar.lz
dexon-c2a494c743e6fd32c5f14415d028432b051f8ea1.tar.xz
dexon-c2a494c743e6fd32c5f14415d028432b051f8ea1.tar.zst
dexon-c2a494c743e6fd32c5f14415d028432b051f8ea1.zip
eth: update default gas price when not mining too
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 7c63fa51d..dc813ed0d 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -76,14 +76,14 @@ type Ethereum struct {
ApiBackend *EthApiBackend
- miner *miner.Miner
- gasPrice *big.Int
- Mining bool
- MinerThreads int
- etherbase common.Address
+ miner *miner.Miner
+ gasPrice *big.Int
+ etherbase common.Address
networkId uint64
netRPCService *ethapi.PublicNetAPI
+
+ lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
}
func (s *Ethereum) AddLesServer(ls LesServer) {
@@ -121,8 +121,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
shutdownChan: make(chan bool),
stopDbUpgrade: stopDbUpgrade,
networkId: config.NetworkId,
+ gasPrice: config.GasPrice,
etherbase: config.Etherbase,
- MinerThreads: config.MinerThreads,
}
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.gasPrice = config.GasPrice
eth.miner.SetExtra(makeExtraData(config.ExtraData))
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) {
- if s.etherbase != (common.Address{}) {
- return s.etherbase, nil
+ s.lock.RLock()
+ etherbase := s.etherbase
+ s.lock.RUnlock()
+
+ if etherbase != (common.Address{}) {
+ return etherbase, nil
}
if wallets := s.AccountManager().Wallets(); len(wallets) > 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
func (self *Ethereum) SetEtherbase(etherbase common.Address) {
+ self.lock.Lock()
self.etherbase = etherbase
+ self.lock.Unlock()
+
self.miner.SetEtherbase(etherbase)
}