mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2025-01-05 10:12:19 +00:00
30 lines
855 B
Go
30 lines
855 B
Go
package parlia
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ethereum/go-ethereum/consensus"
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
)
|
|
|
|
const (
|
|
wiggleTimeBeforeFork = 500 * time.Millisecond // Random delay (per signer) to allow concurrent signers
|
|
fixedBackOffTimeBeforeFork = 200 * time.Millisecond
|
|
)
|
|
|
|
func (p *Parlia) delayForRamanujanFork(snap *Snapshot, header *types.Header) time.Duration {
|
|
return time.Until(time.Unix(int64(header.Time), 0))
|
|
}
|
|
|
|
func (p *Parlia) blockTimeForRamanujanFork(snap *Snapshot, header, parent *types.Header) uint64 {
|
|
return parent.Time + p.config.Period + backOffTime(snap, p.val)
|
|
}
|
|
|
|
func (p *Parlia) blockTimeVerifyForRamanujanFork(snap *Snapshot, header, parent *types.Header) error {
|
|
if header.Time < parent.Time+p.config.Period+backOffTime(snap, header.Coinbase) {
|
|
return consensus.ErrFutureBlock
|
|
}
|
|
|
|
return nil
|
|
}
|