mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
core: fixup comments, remove txs != receipts panic
This commit is contained in:
parent
640613509a
commit
5d8522118e
1 changed files with 4 additions and 7 deletions
|
|
@ -218,9 +218,8 @@ type extblock struct {
|
||||||
// NewBlock creates a new block. The input data is copied, changes to header and to the
|
// NewBlock creates a new block. The input data is copied, changes to header and to the
|
||||||
// field values will not affect the block.
|
// field values will not affect the block.
|
||||||
//
|
//
|
||||||
// The values of TxHash, UncleHash, ReceiptHash and Bloom in header
|
// The body elements and the receipts are used to recompute and overwrite the
|
||||||
// are ignored and set to values derived from the given txs, uncles
|
// relevant portions of the header.
|
||||||
// and receipts.
|
|
||||||
func NewBlock(header *Header, body *Body, receipts []*Receipt, hasher TrieHasher) *Block {
|
func NewBlock(header *Header, body *Body, receipts []*Receipt, hasher TrieHasher) *Block {
|
||||||
if body == nil {
|
if body == nil {
|
||||||
body = &Body{}
|
body = &Body{}
|
||||||
|
|
@ -231,9 +230,6 @@ func NewBlock(header *Header, body *Body, receipts []*Receipt, hasher TrieHasher
|
||||||
uncles = body.Uncles
|
uncles = body.Uncles
|
||||||
withdrawals = body.Withdrawals
|
withdrawals = body.Withdrawals
|
||||||
)
|
)
|
||||||
if len(txs) != len(receipts) {
|
|
||||||
panic("cannot make new block with mismatched number of txs and receipts")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(txs) == 0 {
|
if len(txs) == 0 {
|
||||||
b.header.TxHash = EmptyTxsHash
|
b.header.TxHash = EmptyTxsHash
|
||||||
|
|
@ -454,7 +450,8 @@ func (b *Block) WithSeal(header *Header) *Block {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithBody returns a copy of the block with the given transaction and uncle contents.
|
// WithBody returns a new block with the original header and a deep copy of the
|
||||||
|
// provided body.
|
||||||
func (b *Block) WithBody(body Body) *Block {
|
func (b *Block) WithBody(body Body) *Block {
|
||||||
block := &Block{
|
block := &Block{
|
||||||
header: b.header,
|
header: b.header,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue