Skip to content

Commit

Permalink
core/types: fix witness
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Aug 29, 2024
1 parent 9e2e8f0 commit 5bfe055
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ type Block struct {
transactions Transactions
withdrawals Withdrawals

// witness is not an encoded part of the block body.
// It is held in Block in order for easy relaying to the places
// that process it.
witness *ExecutionWitness

// caches
Expand Down Expand Up @@ -461,6 +464,7 @@ func (b *Block) WithSeal(header *Header) *Block {
transactions: b.transactions,
uncles: b.uncles,
withdrawals: b.withdrawals,
witness: b.witness,
}
}

Expand All @@ -472,6 +476,7 @@ func (b *Block) WithBody(body Body) *Block {
transactions: slices.Clone(body.Transactions),
uncles: make([]*Header, len(body.Uncles)),
withdrawals: slices.Clone(body.Withdrawals),
witness: b.witness,
}
for i := range body.Uncles {
block.uncles[i] = CopyHeader(body.Uncles[i])
Expand All @@ -480,18 +485,13 @@ func (b *Block) WithBody(body Body) *Block {
}

func (b *Block) WithWitness(witness *ExecutionWitness) *Block {

block := &Block{
return &Block{
header: b.header,
transactions: b.transactions,
uncles: make([]*Header, len(b.uncles)),
uncles: b.uncles,
withdrawals: b.withdrawals,
witness: witness,
}
for i := range b.uncles {
block.uncles[i] = b.uncles[i]
}
return block
}

// Hash returns the keccak256 hash of b's header.
Expand Down

0 comments on commit 5bfe055

Please sign in to comment.