aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-04-10 18:24:12 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-10 18:24:12 +0800
commitfeeccdf4ec1084b38dac112ff4f86809efd7c0e5 (patch)
tree90729d779c305fc5e56b5c50316f32bda94258b8 /eth
parentbfe5eb7f8c05c49563b0f1165f98d0a18f0fdbd4 (diff)
downloaddexon-feeccdf4ec1084b38dac112ff4f86809efd7c0e5.tar
dexon-feeccdf4ec1084b38dac112ff4f86809efd7c0e5.tar.gz
dexon-feeccdf4ec1084b38dac112ff4f86809efd7c0e5.tar.bz2
dexon-feeccdf4ec1084b38dac112ff4f86809efd7c0e5.tar.lz
dexon-feeccdf4ec1084b38dac112ff4f86809efd7c0e5.tar.xz
dexon-feeccdf4ec1084b38dac112ff4f86809efd7c0e5.tar.zst
dexon-feeccdf4ec1084b38dac112ff4f86809efd7c0e5.zip
consensus/clique: Proof of Authority (#3753)
This PR is a prototype implementation of plugable consensus engines and the Clique PoA protocol ethereum/EIPs#225
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 6c3ccb9b9..4dffa2990 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
+ "github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -230,6 +231,11 @@ func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Data
// CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service
func CreateConsensusEngine(ctx *node.ServiceContext, config *Config, chainConfig *params.ChainConfig, db ethdb.Database) consensus.Engine {
+ // If proof-of-authority is requested, set it up
+ if chainConfig.Clique != nil {
+ return clique.New(chainConfig.Clique, db)
+ }
+ // Otherwise assume proof-of-work
switch {
case config.PowFake:
log.Warn("Ethash used in fake mode")
@@ -333,6 +339,14 @@ func (s *Ethereum) StartMining(local bool) error {
log.Error("Cannot start mining without etherbase", "err", err)
return fmt.Errorf("etherbase missing: %v", err)
}
+ if clique, ok := s.engine.(*clique.Clique); ok {
+ wallet, err := s.accountManager.Find(accounts.Account{Address: eb})
+ if wallet == nil || err != nil {
+ log.Error("Etherbase account unavailable locally", "err", err)
+ return fmt.Errorf("singer missing: %v", err)
+ }
+ clique.Authorize(eb, wallet.SignHash)
+ }
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