@@ -27,7 +27,6 @@ import (
27
27
"sync"
28
28
"time"
29
29
30
- "github.com/ethereum/go-ethereum/accounts"
31
30
"github.com/ethereum/go-ethereum/common"
32
31
"github.com/ethereum/go-ethereum/common/hexutil"
33
32
"github.com/ethereum/go-ethereum/common/lru"
@@ -140,9 +139,6 @@ var (
140
139
errRecentlySigned = errors .New ("recently signed" )
141
140
)
142
141
143
- // SignerFn hashes and signs the data to be signed by a backing account.
144
- type SignerFn func (signer accounts.Account , mimeType string , message []byte ) ([]byte , error )
145
-
146
142
// ecrecover extracts the Ethereum account address from a signed header.
147
143
func ecrecover (header * types.Header , sigcache * sigLRU ) (common.Address , error ) {
148
144
// If the signature's already cached, return that
@@ -180,7 +176,6 @@ type Clique struct {
180
176
proposals map [common.Address ]bool // Current list of proposals we are pushing
181
177
182
178
signer common.Address // Ethereum address of the signing key
183
- signFn SignerFn // Signer function to authorize hashes with
184
179
lock sync.RWMutex // Protects the signer and proposals fields
185
180
186
181
// The fields below are for testing only
@@ -602,82 +597,17 @@ func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
602
597
603
598
// Authorize injects a private key into the consensus engine to mint new blocks
604
599
// with.
605
- func (c * Clique ) Authorize (signer common.Address , signFn SignerFn ) {
600
+ func (c * Clique ) Authorize (signer common.Address ) {
606
601
c .lock .Lock ()
607
602
defer c .lock .Unlock ()
608
603
609
604
c .signer = signer
610
- c .signFn = signFn
611
605
}
612
606
613
607
// Seal implements consensus.Engine, attempting to create a sealed block using
614
608
// the local signing credentials.
615
609
func (c * Clique ) Seal (chain consensus.ChainHeaderReader , block * types.Block , results chan <- * types.Block , stop <- chan struct {}) error {
616
- header := block .Header ()
617
-
618
- // Sealing the genesis block is not supported
619
- number := header .Number .Uint64 ()
620
- if number == 0 {
621
- return errUnknownBlock
622
- }
623
- // For 0-period chains, refuse to seal empty blocks (no reward but would spin sealing)
624
- if c .config .Period == 0 && len (block .Transactions ()) == 0 {
625
- return errors .New ("sealing paused while waiting for transactions" )
626
- }
627
- // Don't hold the signer fields for the entire sealing procedure
628
- c .lock .RLock ()
629
- signer , signFn := c .signer , c .signFn
630
- c .lock .RUnlock ()
631
-
632
- // Bail out if we're unauthorized to sign a block
633
- snap , err := c .snapshot (chain , number - 1 , header .ParentHash , nil )
634
- if err != nil {
635
- return err
636
- }
637
- if _ , authorized := snap .Signers [signer ]; ! authorized {
638
- return errUnauthorizedSigner
639
- }
640
- // If we're amongst the recent signers, wait for the next block
641
- for seen , recent := range snap .Recents {
642
- if recent == signer {
643
- // Signer is among recents, only wait if the current block doesn't shift it out
644
- if limit := uint64 (len (snap .Signers )/ 2 + 1 ); number < limit || seen > number - limit {
645
- return errors .New ("signed recently, must wait for others" )
646
- }
647
- }
648
- }
649
- // Sweet, the protocol permits us to sign the block, wait for our time
650
- delay := time .Unix (int64 (header .Time ), 0 ).Sub (time .Now ()) // nolint: gosimple
651
- if header .Difficulty .Cmp (diffNoTurn ) == 0 {
652
- // It's not our turn explicitly to sign, delay it a bit
653
- wiggle := time .Duration (len (snap .Signers )/ 2 + 1 ) * wiggleTime
654
- delay += time .Duration (rand .Int63n (int64 (wiggle )))
655
-
656
- log .Trace ("Out-of-turn signing requested" , "wiggle" , common .PrettyDuration (wiggle ))
657
- }
658
- // Sign all the things!
659
- sighash , err := signFn (accounts.Account {Address : signer }, accounts .MimetypeClique , CliqueRLP (header ))
660
- if err != nil {
661
- return err
662
- }
663
- copy (header .Extra [len (header .Extra )- extraSeal :], sighash )
664
- // Wait until sealing is terminated or delay timeout.
665
- log .Trace ("Waiting for slot to sign and propagate" , "delay" , common .PrettyDuration (delay ))
666
- go func () {
667
- select {
668
- case <- stop :
669
- return
670
- case <- time .After (delay ):
671
- }
672
-
673
- select {
674
- case results <- block .WithSeal (header ):
675
- default :
676
- log .Warn ("Sealing result is not read by miner" , "sealhash" , SealHash (header ))
677
- }
678
- }()
679
-
680
- return nil
610
+ panic ("clique (poa) sealing not supported any more" )
681
611
}
682
612
683
613
// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty
0 commit comments