aboutsummaryrefslogtreecommitdiff
path: root/core/types/block.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/types/block.go')
-rw-r--r--core/types/block.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/core/types/block.go b/core/types/block.go
index b3dbcd3..4096d86 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -144,6 +144,8 @@ func rlpHash(x interface{}) (h common.Hash) {
type Body struct {
Transactions []*Transaction
Uncles []*Header
+ Version uint32
+ ExtData []byte `rlp:"nil"`
}
// Block represents an entire block in the Ethereum blockchain.
@@ -212,7 +214,7 @@ type storageblock struct {
// The values of TxHash, UncleHash, ReceiptHash and Bloom in header
// are ignored and set to values derived from the given txs, uncles
// and receipts.
-func NewBlock(header *Header, txs []*Transaction, uncles []*Header, receipts []*Receipt) *Block {
+func NewBlock(header *Header, txs []*Transaction, uncles []*Header, receipts []*Receipt, extdata []byte) *Block {
b := &Block{header: CopyHeader(header), td: new(big.Int)}
// TODO: panic if len(txs) != len(receipts)
@@ -241,6 +243,9 @@ func NewBlock(header *Header, txs []*Transaction, uncles []*Header, receipts []*
}
}
+ b.extdata = make([]byte, len(extdata))
+ copy(b.extdata, extdata)
+
return b
}
@@ -387,7 +392,7 @@ func (b *Block) Extra() []byte { return common.CopyBytes(b.header.Ext
func (b *Block) Header() *Header { return CopyHeader(b.header) }
// Body returns the non-header content of the block.
-func (b *Block) Body() *Body { return &Body{b.transactions, b.uncles} }
+func (b *Block) Body() *Body { return &Body{b.transactions, b.uncles, b.version, b.extdata} }
// Size returns the true RLP encoded storage size of the block, either by encoding
// and returning it, or returning a previsouly cached value.
@@ -434,13 +439,16 @@ func (b *Block) WithSeal(header *Header) *Block {
}
// WithBody returns a new block with the given transaction and uncle contents.
-func (b *Block) WithBody(transactions []*Transaction, uncles []*Header) *Block {
+func (b *Block) WithBody(transactions []*Transaction, uncles []*Header, version uint32, extdata []byte) *Block {
block := &Block{
header: CopyHeader(b.header),
transactions: make([]*Transaction, len(transactions)),
uncles: make([]*Header, len(uncles)),
+ extdata: make([]byte, len(extdata)),
+ version: version,
}
copy(block.transactions, transactions)
+ copy(block.extdata, extdata)
for i := range uncles {
block.uncles[i] = CopyHeader(uncles[i])
}