mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
fix bug on no committing new block (#29)
This commit is contained in:
parent
1ecbde748c
commit
8b16b4cefa
2 changed files with 11 additions and 7 deletions
|
|
@ -123,6 +123,10 @@ var (
|
||||||
// turn of the signer.
|
// turn of the signer.
|
||||||
errWrongDifficulty = errors.New("wrong difficulty")
|
errWrongDifficulty = errors.New("wrong difficulty")
|
||||||
|
|
||||||
|
// errInvalidTimestamp is returned if the timestamp of a block is lower than
|
||||||
|
// the previous block's timestamp + the minimum block period.
|
||||||
|
errInvalidTimestamp = errors.New("invalid timestamp")
|
||||||
|
|
||||||
// errInvalidVotingChain is returned if an authorization list is attempted to
|
// errInvalidVotingChain is returned if an authorization list is attempted to
|
||||||
// be modified via out-of-range or non-contiguous headers.
|
// be modified via out-of-range or non-contiguous headers.
|
||||||
errInvalidVotingChain = errors.New("invalid voting chain")
|
errInvalidVotingChain = errors.New("invalid voting chain")
|
||||||
|
|
@ -323,9 +327,9 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
|
||||||
if parent == nil || parent.Number.Uint64() != number-1 || parent.Hash() != header.ParentHash {
|
if parent == nil || parent.Number.Uint64() != number-1 || parent.Hash() != header.ParentHash {
|
||||||
return consensus.ErrUnknownAncestor
|
return consensus.ErrUnknownAncestor
|
||||||
}
|
}
|
||||||
/*if parent.Time+c.config.Period > header.Time {
|
if parent.Time+c.config.Period > header.Time {
|
||||||
return errInvalidTimestamp
|
return errInvalidTimestamp
|
||||||
}*/
|
}
|
||||||
// Verify that the gasUsed is <= gasLimit
|
// Verify that the gasUsed is <= gasLimit
|
||||||
if header.GasUsed > header.GasLimit {
|
if header.GasUsed > header.GasLimit {
|
||||||
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
|
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
|
||||||
|
|
@ -549,10 +553,10 @@ func (c *Clique) Prepare(chain consensus.ChainHeaderReader, header *types.Header
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
return consensus.ErrUnknownAncestor
|
return consensus.ErrUnknownAncestor
|
||||||
}
|
}
|
||||||
//header.Time = parent.Time + c.config.Period
|
header.Time = parent.Time + c.config.Period
|
||||||
//if header.Time < uint64(time.Now().Unix()) {
|
if header.Time < uint64(time.Now().Unix()) {
|
||||||
header.Time = uint64(time.Now().Unix())
|
header.Time = uint64(time.Now().Unix())
|
||||||
//}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
|
||||||
case head := <-w.chainHeadCh:
|
case head := <-w.chainHeadCh:
|
||||||
clearPending(head.Block.NumberU64())
|
clearPending(head.Block.NumberU64())
|
||||||
timestamp = time.Now().Unix()
|
timestamp = time.Now().Unix()
|
||||||
// commit(false, commitInterruptNewHead)
|
commit(true, commitInterruptNewHead)
|
||||||
|
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
// If mining is running resubmit a new work cycle periodically to pull in
|
// If mining is running resubmit a new work cycle periodically to pull in
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue