mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
adjust signed recently condition
This commit is contained in:
parent
e20d9797ff
commit
30ae355fd1
2 changed files with 26 additions and 19 deletions
|
|
@ -20,12 +20,12 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"gopkg.in/urfave/cli.v1"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"unicode"
|
|
||||||
"strings"
|
"strings"
|
||||||
"gopkg.in/urfave/cli.v1"
|
"unicode"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/dashboard"
|
"github.com/ethereum/go-ethereum/dashboard"
|
||||||
|
|
|
||||||
|
|
@ -575,13 +575,16 @@ func (c *Posv) verifySeal(chain consensus.ChainReader, header *types.Header, par
|
||||||
return errUnauthorized
|
return errUnauthorized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for seen, recent := range snap.Recents {
|
if len(masternodes) > 1 {
|
||||||
if recent == signer {
|
for seen, recent := range snap.Recents {
|
||||||
// Signer is among recents, only fail if the current block doesn't shift it out
|
if recent == signer {
|
||||||
if limit := uint64(len(masternodes)/2 + 1); seen > number-limit {
|
// Signer is among recents, only fail if the current block doesn't shift it out
|
||||||
// Only take into account the non-epoch blocks
|
// There is only case that we don't allow signer to create two continuous blocks.
|
||||||
if number%c.config.Epoch != 0 {
|
if limit := uint64(2); seen > number-limit {
|
||||||
return errUnauthorized
|
// Only take into account the non-epoch blocks
|
||||||
|
if number%c.config.Epoch != 0 {
|
||||||
|
return errUnauthorized
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -755,16 +758,20 @@ func (c *Posv) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If we're amongst the recent signers, wait for the next block
|
// If we're amongst the recent signers, wait for the next block
|
||||||
for seen, recent := range snap.Recents {
|
// only check recent signers if there are more than one signer.
|
||||||
if recent == signer {
|
if len(masternodes) > 1 {
|
||||||
// Signer is among recents, only wait if the current block doesn't shift it out
|
for seen, recent := range snap.Recents {
|
||||||
if limit := uint64(len(masternodes)/2 + 1); number < limit || seen > number-limit {
|
if recent == signer {
|
||||||
// Only take into account the non-epoch blocks
|
// Signer is among recents, only wait if the current block doesn't shift it out
|
||||||
if number%c.config.Epoch != 0 {
|
// There is only case that we don't allow signer to create two continuous blocks.
|
||||||
log.Info("Debugging", "len(masternodes)", len(masternodes), "number", number, "limit", limit, "seen", seen, "recent", recent.String(), "snap.Recents", snap.Recents)
|
if limit := uint64(2); number < limit || seen > number-limit {
|
||||||
log.Info("Signed recently, must wait for others")
|
// Only take into account the non-epoch blocks
|
||||||
<-stop
|
if number%c.config.Epoch != 0 {
|
||||||
return nil, nil
|
log.Info("Debugging", "len(masternodes)", len(masternodes), "number", number, "limit", limit, "seen", seen, "recent", recent.String(), "snap.Recents", snap.Recents)
|
||||||
|
log.Info("Signed recently, must wait for others")
|
||||||
|
<-stop
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue