diff options
Diffstat (limited to 'core/types')
-rw-r--r-- | core/types/block.go | 9 | ||||
-rw-r--r-- | core/types/block_test.go | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/core/types/block.go b/core/types/block.go index 427a3e6cb..2188e6d4d 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -60,7 +60,7 @@ type Header struct { Number *big.Int // The block number GasLimit *big.Int // Gas limit GasUsed *big.Int // Gas used - Time uint64 // Creation time + Time *big.Int // Creation time Extra []byte // Extra data MixDigest common.Hash // for quick difficulty verification Nonce BlockNonce @@ -94,7 +94,7 @@ func (h *Header) UnmarshalJSON(data []byte) error { Coinbase string Difficulty string GasLimit string - Time uint64 + Time *big.Int Extra string } dec := json.NewDecoder(bytes.NewReader(data)) @@ -210,6 +210,9 @@ func NewBlockWithHeader(header *Header) *Block { func copyHeader(h *Header) *Header { cpy := *h + if cpy.Time = new(big.Int); h.Time != nil { + cpy.Time.Set(h.Time) + } if cpy.Difficulty = new(big.Int); h.Difficulty != nil { cpy.Difficulty.Set(h.Difficulty) } @@ -301,13 +304,13 @@ func (b *Block) Number() *big.Int { return new(big.Int).Set(b.header.Number) func (b *Block) GasLimit() *big.Int { return new(big.Int).Set(b.header.GasLimit) } func (b *Block) GasUsed() *big.Int { return new(big.Int).Set(b.header.GasUsed) } func (b *Block) Difficulty() *big.Int { return new(big.Int).Set(b.header.Difficulty) } +func (b *Block) Time() *big.Int { return new(big.Int).Set(b.header.Time) } func (b *Block) NumberU64() uint64 { return b.header.Number.Uint64() } func (b *Block) MixDigest() common.Hash { return b.header.MixDigest } func (b *Block) Nonce() uint64 { return binary.BigEndian.Uint64(b.header.Nonce[:]) } func (b *Block) Bloom() Bloom { return b.header.Bloom } func (b *Block) Coinbase() common.Address { return b.header.Coinbase } -func (b *Block) Time() uint64 { return b.header.Time } func (b *Block) Root() common.Hash { return b.header.Root } func (b *Block) ParentHash() common.Hash { return b.header.ParentHash } func (b *Block) TxHash() common.Hash { return b.header.TxHash } diff --git a/core/types/block_test.go b/core/types/block_test.go index aebb6328b..cdd8431f4 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -47,7 +47,7 @@ func TestBlockEncoding(t *testing.T) { check("Root", block.Root(), common.HexToHash("ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017")) check("Hash", block.Hash(), common.HexToHash("0a5843ac1cb04865017cb35a57b50b07084e5fcee39b5acadade33149f4fff9e")) check("Nonce", block.Nonce(), uint64(0xa13a5a8c8f2bb1c4)) - check("Time", block.Time(), uint64(1426516743)) + check("Time", block.Time(), big.NewInt(1426516743)) check("Size", block.Size(), common.StorageSize(len(blockEnc))) tx1 := NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(10), big.NewInt(50000), big.NewInt(10), nil) |