NewBlock creates a new block. The input data is copied, changes to header and to the field values will not affect the block. The values of TxsRoot, UncleHash, ReceiptsRoot and LogsBloom in header are ignored and set to values derived from the given txs, uncles and receipts.
(header *Header, txs []*Transaction, receipts []*Receipt)
| 303 | // are ignored and set to values derived from the given txs, uncles |
| 304 | // and receipts. |
| 305 | func NewBlock(header *Header, txs []*Transaction, receipts []*Receipt) *Block { |
| 306 | b := &Block{header: CopyHeader(header), td: new(big.Int)} |
| 307 | |
| 308 | // TODO: panic if len(txs) != len(receipts) |
| 309 | if len(txs) == 0 { |
| 310 | b.header.TxsRoot = EmptyRootHash |
| 311 | } else { |
| 312 | b.header.TxsRoot = DeriveSha(Transactions(txs)) |
| 313 | b.transactions = make(Transactions, len(txs)) |
| 314 | copy(b.transactions, txs) |
| 315 | } |
| 316 | |
| 317 | if len(receipts) == 0 { |
| 318 | b.header.ReceiptsRoot = EmptyRootHash |
| 319 | } else { |
| 320 | b.header.ReceiptsRoot = DeriveSha(Receipts(receipts)) |
| 321 | b.header.LogsBloom = CreateBloom(receipts) |
| 322 | } |
| 323 | |
| 324 | return b |
| 325 | } |
| 326 | |
| 327 | // NewBlockWithHeader creates a block with the given header data. The |
| 328 | // header data is copied, changes to header and to the field values |
nothing calls this directly
no test coverage detected