@@ -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"
@@ -50,8 +49,6 @@ const (
50
49
checkpointInterval = 1024 // Number of blocks after which to save the vote snapshot to the database
51
50
inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory
52
51
inmemorySignatures = 4096 // Number of recent block signatures to keep in memory
53
-
54
- wiggleTime = 500 * time .Millisecond // Random delay (per signer) to allow concurrent signers
55
52
)
56
53
57
54
// Clique proof-of-authority protocol constants.
@@ -140,9 +137,6 @@ var (
140
137
errRecentlySigned = errors .New ("recently signed" )
141
138
)
142
139
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
140
// ecrecover extracts the Ethereum account address from a signed header.
147
141
func ecrecover (header * types.Header , sigcache * sigLRU ) (common.Address , error ) {
148
142
// If the signature's already cached, return that
@@ -180,7 +174,6 @@ type Clique struct {
180
174
proposals map [common.Address ]bool // Current list of proposals we are pushing
181
175
182
176
signer common.Address // Ethereum address of the signing key
183
- signFn SignerFn // Signer function to authorize hashes with
184
177
lock sync.RWMutex // Protects the signer and proposals fields
185
178
186
179
// The fields below are for testing only
@@ -602,82 +595,17 @@ func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
602
595
603
596
// Authorize injects a private key into the consensus engine to mint new blocks
604
597
// with.
605
- func (c * Clique ) Authorize (signer common.Address , signFn SignerFn ) {
598
+ func (c * Clique ) Authorize (signer common.Address ) {
606
599
c .lock .Lock ()
607
600
defer c .lock .Unlock ()
608
601
609
602
c .signer = signer
610
- c .signFn = signFn
611
603
}
612
604
613
605
// Seal implements consensus.Engine, attempting to create a sealed block using
614
606
// the local signing credentials.
615
607
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
608
+ panic ("clique (poa) sealing not supported any more" )
681
609
}
682
610
683
611
// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty
0 commit comments