aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_makers.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-08-24 08:52:53 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-08-25 10:46:11 +0800
commit7324176f702a77fc331bf16a968d2eb4bccce021 (patch)
treea9fef3b9ee46fc382dde23cdd90209cc4298dd59 /core/chain_makers.go
parentd51d0022cee91d6588186455afbe6e54fae2cbf7 (diff)
downloadgo-tangerine-7324176f702a77fc331bf16a968d2eb4bccce021.tar
go-tangerine-7324176f702a77fc331bf16a968d2eb4bccce021.tar.gz
go-tangerine-7324176f702a77fc331bf16a968d2eb4bccce021.tar.bz2
go-tangerine-7324176f702a77fc331bf16a968d2eb4bccce021.tar.lz
go-tangerine-7324176f702a77fc331bf16a968d2eb4bccce021.tar.xz
go-tangerine-7324176f702a77fc331bf16a968d2eb4bccce021.tar.zst
go-tangerine-7324176f702a77fc331bf16a968d2eb4bccce021.zip
Add tests for uncle timestamps and refactor timestamp type
Diffstat (limited to 'core/chain_makers.go')
-rw-r--r--core/chain_makers.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/chain_makers.go b/core/chain_makers.go
index 0bb1df95a..b009e0c28 100644
--- a/core/chain_makers.go
+++ b/core/chain_makers.go
@@ -166,16 +166,21 @@ func GenerateChain(parent *types.Block, db common.Database, n int, gen func(int,
}
func makeHeader(parent *types.Block, state *state.StateDB) *types.Header {
- time := parent.Time() + 10 // block time is fixed at 10 seconds
+ var time *big.Int
+ if parent.Time() == nil {
+ time = big.NewInt(10)
+ } else {
+ time = new(big.Int).Add(parent.Time(), big.NewInt(10)) // block time is fixed at 10 seconds
+ }
return &types.Header{
Root: state.Root(),
ParentHash: parent.Hash(),
Coinbase: parent.Coinbase(),
- Difficulty: CalcDifficulty(time, parent.Time(), parent.Number(), parent.Difficulty()),
+ Difficulty: CalcDifficulty(time.Uint64(), new(big.Int).Sub(time, big.NewInt(10)).Uint64(), parent.Number(), parent.Difficulty()),
GasLimit: CalcGasLimit(parent),
GasUsed: new(big.Int),
Number: new(big.Int).Add(parent.Number(), common.Big1),
- Time: uint64(time),
+ Time: time,
}
}