mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
allow overwriting block hash
This commit is contained in:
parent
7e26589b67
commit
f7ed2af11e
1 changed files with 20 additions and 15 deletions
|
|
@ -191,10 +191,10 @@ type Body struct {
|
|||
// - We do not copy body data on access because it does not affect the caches, and also
|
||||
// because it would be too expensive.
|
||||
type Block struct {
|
||||
Header_ *Header
|
||||
uncles []*Header
|
||||
Txs Transactions
|
||||
withdrawals Withdrawals
|
||||
Header_ *Header
|
||||
uncles []*Header
|
||||
Txs Transactions
|
||||
withdrawals Withdrawals
|
||||
|
||||
// caches
|
||||
hash atomic.Value
|
||||
|
|
@ -446,20 +446,20 @@ func NewBlockWithHeader(header *Header) *Block {
|
|||
// the sealed one.
|
||||
func (b *Block) WithSeal(header *Header) *Block {
|
||||
return &Block{
|
||||
Header_: CopyHeader(header),
|
||||
Txs: b.Txs,
|
||||
uncles: b.uncles,
|
||||
withdrawals: b.withdrawals,
|
||||
Header_: CopyHeader(header),
|
||||
Txs: b.Txs,
|
||||
uncles: b.uncles,
|
||||
withdrawals: b.withdrawals,
|
||||
}
|
||||
}
|
||||
|
||||
// WithBody returns a copy of the block with the given transaction and uncle contents.
|
||||
func (b *Block) WithBody(transactions []*Transaction, uncles []*Header) *Block {
|
||||
block := &Block{
|
||||
Header_: b.Header_,
|
||||
Txs: make([]*Transaction, len(transactions)),
|
||||
uncles: make([]*Header, len(uncles)),
|
||||
withdrawals: b.withdrawals,
|
||||
Header_: b.Header_,
|
||||
Txs: make([]*Transaction, len(transactions)),
|
||||
uncles: make([]*Header, len(uncles)),
|
||||
withdrawals: b.withdrawals,
|
||||
}
|
||||
copy(block.Txs, transactions)
|
||||
for i := range uncles {
|
||||
|
|
@ -471,9 +471,9 @@ func (b *Block) WithBody(transactions []*Transaction, uncles []*Header) *Block {
|
|||
// WithWithdrawals returns a copy of the block containing the given withdrawals.
|
||||
func (b *Block) WithWithdrawals(withdrawals []*Withdrawal) *Block {
|
||||
block := &Block{
|
||||
Header_: b.Header_,
|
||||
Txs: b.Txs,
|
||||
uncles: b.uncles,
|
||||
Header_: b.Header_,
|
||||
Txs: b.Txs,
|
||||
uncles: b.uncles,
|
||||
}
|
||||
if withdrawals != nil {
|
||||
block.withdrawals = make([]*Withdrawal, len(withdrawals))
|
||||
|
|
@ -493,6 +493,11 @@ func (b *Block) Hash() common.Hash {
|
|||
return v
|
||||
}
|
||||
|
||||
// Used by tracer/simulation. Should never be called in actual execution.
|
||||
func (b *Block) OverwriteHash(h common.Hash) {
|
||||
b.hash.Store(h)
|
||||
}
|
||||
|
||||
type Blocks []*Block
|
||||
|
||||
// HeaderParentHashFromRLP returns the parentHash of an RLP-encoded
|
||||
|
|
|
|||
Loading…
Reference in a new issue