aboutsummaryrefslogtreecommitdiffstats
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, 14 insertions, 0 deletions
diff --git a/core/types/block.go b/core/types/block.go
index 2188e6d4d..fd81db04c 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -360,6 +360,20 @@ func (b *Block) WithMiningResult(nonce uint64, mixDigest common.Hash) *Block {
}
}
+// WithBody returns a new block with the given transaction and uncle contents.
+func (b *Block) WithBody(transactions []*Transaction, uncles []*Header) *Block {
+ block := &Block{
+ header: copyHeader(b.header),
+ transactions: make([]*Transaction, len(transactions)),
+ uncles: make([]*Header, len(uncles)),
+ }
+ copy(block.transactions, transactions)
+ for i := range uncles {
+ block.uncles[i] = copyHeader(uncles[i])
+ }
+ return block
+}
+
// Implement pow.Block
func (b *Block) Hash() common.Hash {