eth: accept transactions when starting CPU mining (#13882)

This commit is contained in:
Péter Szilágyi
2017-04-10 11:43:01 +03:00
committed by Felix Lange
parent f32b72ca5d
commit bfe5eb7f8c
6 changed files with 18 additions and 10 deletions

View File

@ -22,6 +22,7 @@ import (
"math/big"
"regexp"
"sync"
"sync/atomic"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
@ -326,12 +327,19 @@ func (self *Ethereum) SetEtherbase(etherbase common.Address) {
self.miner.SetEtherbase(etherbase)
}
func (s *Ethereum) StartMining() error {
func (s *Ethereum) StartMining(local bool) error {
eb, err := s.Etherbase()
if err != nil {
log.Error("Cannot start mining without etherbase", "err", err)
return fmt.Errorf("etherbase missing: %v", err)
}
if local {
// If local (CPU) mining is started, we can disable the transaction rejection
// mechanism introduced to speed sync times. CPU mining on mainnet is ludicrous
// so noone will ever hit this path, whereas marking sync done on CPU mining
// will ensure that private networks work in single miner mode too.
atomic.StoreUint32(&s.protocolManager.acceptTxs, 1)
}
go s.miner.Start(eb)
return nil
}