diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-11-02 12:43:39 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 1f96be77a55876efd22d1e2f7887941ede7b70c0 (patch) | |
tree | 78de5c93e2e653c35817ed35eff193a2e879ad97 /vendor/github.com | |
parent | ecd02bb80782799065ecc66eea3129317f8ed513 (diff) | |
download | dexon-1f96be77a55876efd22d1e2f7887941ede7b70c0.tar dexon-1f96be77a55876efd22d1e2f7887941ede7b70c0.tar.gz dexon-1f96be77a55876efd22d1e2f7887941ede7b70c0.tar.bz2 dexon-1f96be77a55876efd22d1e2f7887941ede7b70c0.tar.lz dexon-1f96be77a55876efd22d1e2f7887941ede7b70c0.tar.xz dexon-1f96be77a55876efd22d1e2f7887941ede7b70c0.tar.zst dexon-1f96be77a55876efd22d1e2f7887941ede7b70c0.zip |
core: vm: governance: remove maxInterval
Diffstat (limited to 'vendor/github.com')
3 files changed, 10 insertions, 21 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go index 7e6934f45..cec3c4f64 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -367,6 +367,9 @@ func NewConsensus( } validLeader := func(block *types.Block) bool { + if block.Timestamp.After(time.Now()) { + return false + } return lattice.SanityCheck(block) == nil } diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go index 564675730..ca246612d 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice-data.go @@ -73,28 +73,24 @@ type latticeDataConfig struct { // Block interval specifies reasonable time difference between // parent/child blocks. minBlockTimeInterval time.Duration - maxBlockTimeInterval time.Duration } // Initiate latticeDataConfig from types.Config. func (config *latticeDataConfig) fromConfig(roundID uint64, cfg *types.Config) { config.numChains = cfg.NumChains config.minBlockTimeInterval = cfg.MinBlockInterval - config.maxBlockTimeInterval = cfg.MaxBlockInterval config.setupRoundBasedFields(roundID, cfg) } // Check if timestamp of a block is valid according to a reference time. func (config *latticeDataConfig) isValidBlockTime( b *types.Block, ref time.Time) bool { - return !(b.Timestamp.Before(ref.Add(config.minBlockTimeInterval)) || - b.Timestamp.After(ref.Add(config.maxBlockTimeInterval))) + return !b.Timestamp.Before(ref.Add(config.minBlockTimeInterval)) } // isValidGenesisBlockTime check if a timestamp is valid for a genesis block. func (config *latticeDataConfig) isValidGenesisBlockTime(b *types.Block) bool { - return !(b.Timestamp.Before(config.roundBeginTime) || b.Timestamp.After( - config.roundBeginTime.Add(config.maxBlockTimeInterval))) + return !b.Timestamp.Before(config.roundBeginTime) } // newGenesisLatticeDataConfig constructs a latticeDataConfig instance. @@ -380,11 +376,11 @@ func (data *latticeData) addFinalizedBlock( // genesis block. func (data *latticeData) prepareBlock(b *types.Block) error { var ( - minTimestamp, maxTimestamp time.Time - config *latticeDataConfig - acks common.Hashes - bindTip bool - chainTip *types.Block + minTimestamp time.Time + config *latticeDataConfig + acks common.Hashes + bindTip bool + chainTip *types.Block ) if config = data.getConfig(b.Position.Round); config == nil { return ErrUnknownRoundID @@ -425,7 +421,6 @@ func (data *latticeData) prepareBlock(b *types.Block) error { // parent block and bound config. if bindTip { minTimestamp = chainTip.Timestamp.Add(config.minBlockTimeInterval) - maxTimestamp = chainTip.Timestamp.Add(config.maxBlockTimeInterval) // When a chain is removed and added back, the reference block // of previous round can't be used as parent block. b.ParentHash = chainTip.Hash @@ -434,13 +429,10 @@ func (data *latticeData) prepareBlock(b *types.Block) error { // Discontinuous round ID detected, another fresh start of // new round. minTimestamp = config.roundBeginTime - maxTimestamp = config.roundBeginTime.Add(config.maxBlockTimeInterval) } // Fix timestamp if the given one is invalid. if b.Timestamp.Before(minTimestamp) { b.Timestamp = minTimestamp - } else if b.Timestamp.After(maxTimestamp) { - b.Timestamp = maxTimestamp } // Setup acks fields. for _, status := range data.chains { diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go index 975eec9cb..c9d31f8c4 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go @@ -43,7 +43,6 @@ type Config struct { // Time related. RoundInterval time.Duration MinBlockInterval time.Duration - MaxBlockInterval time.Duration } // Clone return a copied configuration. @@ -58,7 +57,6 @@ func (c *Config) Clone() *Config { DKGSetSize: c.DKGSetSize, RoundInterval: c.RoundInterval, MinBlockInterval: c.MinBlockInterval, - MaxBlockInterval: c.MaxBlockInterval, } } @@ -90,9 +88,6 @@ func (c *Config) Bytes() []byte { binaryMinBlockInterval := make([]byte, 8) binary.LittleEndian.PutUint64(binaryMinBlockInterval, uint64(c.MinBlockInterval.Nanoseconds())) - binaryMaxBlockInterval := make([]byte, 8) - binary.LittleEndian.PutUint64(binaryMaxBlockInterval, - uint64(c.MaxBlockInterval.Nanoseconds())) enc := make([]byte, 0, 40) enc = append(enc, binaryNumChains...) @@ -104,6 +99,5 @@ func (c *Config) Bytes() []byte { enc = append(enc, binaryDKGSetSize...) enc = append(enc, binaryRoundInterval...) enc = append(enc, binaryMinBlockInterval...) - enc = append(enc, binaryMaxBlockInterval...) return enc } |