Skip to content

Commit

Permalink
Engine/create (#12)
Browse files Browse the repository at this point in the history
* added aura to createConsensusEngine

* consensus engine create
  • Loading branch information
dutterbutter authored and ansermino committed Sep 8, 2018
1 parent d08315e commit 7250469
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion consensus/aura/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ type Aura struct {
lock sync.RWMutex // Protects the signer fields
}

// New creates a Clique proof-of-authority consensus engine with the initial
// New creates a Aura proof-of-authority consensus engine with the initial
// signers set to the ones provided by the user.
func New(config *params.AuraConfig, db ethdb.Database) *Aura {
// Set any missing consensus parameters to their defaults
Expand Down
12 changes: 12 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/consensus/aura"
)

type LesServer interface {
Expand Down Expand Up @@ -220,6 +221,8 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo
// If proof-of-authority is requested, set it up
if chainConfig.Clique != nil {
return clique.New(chainConfig.Clique, db)
} else if chainConfig.Aura != nil {
return aura.New(chainConfig.Aura, db)
}
// Otherwise assume proof-of-work
switch config.PowMode {
Expand Down Expand Up @@ -375,6 +378,15 @@ func (s *Ethereum) StartMining(threads int) error {
return fmt.Errorf("signer missing: %v", err)
}
clique.Authorize(eb, wallet.SignHash)
} else {
if aura, ok := s.engine.(*aura.Aura); ok {
wallet, e := s.accountManager.Find(accounts.Account{Address: eb})
if wallet == nil || e != nil {
log.Error("Etherbase account unavailable locally", "err", err)
return fmt.Errorf("signer missing: %v", err)
}
aura.Authorize(eb, wallet.SignHash)
}
}
// If mining is started, we can disable the transaction rejection mechanism
// introduced to speed sync times.
Expand Down

0 comments on commit 7250469

Please sign in to comment.