diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-04-10 16:43:01 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-04-10 16:43:01 +0800 |
commit | bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4 (patch) | |
tree | 724676c86df67ae523cbfda2600e7ba466b2955d /eth/backend.go | |
parent | f32b72ca5d7c477e5f5d3ab0d5b6548bf3fdc139 (diff) | |
download | dexon-bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4.tar dexon-bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4.tar.gz dexon-bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4.tar.bz2 dexon-bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4.tar.lz dexon-bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4.tar.xz dexon-bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4.tar.zst dexon-bfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4.zip |
eth: accept transactions when starting CPU mining (#13882)
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/eth/backend.go b/eth/backend.go index df5460201..6c3ccb9b9 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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 } |