aboutsummaryrefslogtreecommitdiffstats
path: root/core/lattice-data.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-04 17:26:46 +0800
committerGitHub <noreply@github.com>2018-10-04 17:26:46 +0800
commit6773c56fe29511aca0f4345e9fd3758ca05e174f (patch)
tree4cac43ea71124e9fea092397756e1b0f8ce38f01 /core/lattice-data.go
parent604dd7e52c8cbffd7646205c464f7333d215ceb6 (diff)
downloadtangerine-consensus-6773c56fe29511aca0f4345e9fd3758ca05e174f.tar
tangerine-consensus-6773c56fe29511aca0f4345e9fd3758ca05e174f.tar.gz
tangerine-consensus-6773c56fe29511aca0f4345e9fd3758ca05e174f.tar.bz2
tangerine-consensus-6773c56fe29511aca0f4345e9fd3758ca05e174f.tar.lz
tangerine-consensus-6773c56fe29511aca0f4345e9fd3758ca05e174f.tar.xz
tangerine-consensus-6773c56fe29511aca0f4345e9fd3758ca05e174f.tar.zst
tangerine-consensus-6773c56fe29511aca0f4345e9fd3758ca05e174f.zip
core: Use event to run DKG and CRS in Consensus. (#171)
Diffstat (limited to 'core/lattice-data.go')
-rw-r--r--core/lattice-data.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/lattice-data.go b/core/lattice-data.go
index 7eec7f2..75447c6 100644
--- a/core/lattice-data.go
+++ b/core/lattice-data.go
@@ -43,7 +43,7 @@ var (
ErrAcksNotSorted = fmt.Errorf("acks not sorted")
ErrInvalidBlockHeight = fmt.Errorf("invalid block height")
ErrAlreadyInLattice = fmt.Errorf("block already in lattice")
- ErrIncorrectBlockTime = fmt.Errorf("block timestampe is incorrect")
+ ErrIncorrectBlockTime = fmt.Errorf("block timestamp is incorrect")
)
// Errors for method usage
@@ -271,6 +271,13 @@ func (data *latticeData) prepareBlock(block *types.Block) {
block.ParentHash = curBlock.Hash
block.Position.Height = curBlock.Position.Height + 1
block.Witness.Height = curBlock.Witness.Height
+ minTimestamp := curBlock.Timestamp.Add(data.minBlockTimeInterval)
+ maxTimestamp := curBlock.Timestamp.Add(data.maxBlockTimeInterval)
+ if block.Timestamp.Before(minTimestamp) {
+ block.Timestamp = minTimestamp
+ } else if block.Timestamp.After(maxTimestamp) {
+ block.Timestamp = maxTimestamp
+ }
}
}
block.Acks = common.NewSortedHashes(acks)