AddTxWithChain adds a transaction to the generated block. If no coinbase has been set, the block's coinbase is set to the zero address. AddTxWithChain panics if the transaction cannot be executed. In addition to the protocol-imposed limitations (gas limit, etc.), there are some further limitations
(bc *BlockChain, tx *types.Transaction)
| 87 | // added. If contract code relies on the BLOCKHASH instruction, |
| 88 | // the block in chain will be returned. |
| 89 | func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) { |
| 90 | if b.gasPool == nil { |
| 91 | b.SetCoinbase(common.Address{}) |
| 92 | } |
| 93 | b.pubStateDB.Prepare(tx.Hash(), common.Hash{}, len(b.txs)) |
| 94 | b.privStateDB.Prepare(tx.Hash(), common.Hash{}, len(b.txs)) |
| 95 | |
| 96 | var remoteDB database.RemoteDatabase |
| 97 | if bc != nil { |
| 98 | remoteDB = bc.remoteDB |
| 99 | } |
| 100 | receipt, _, _, err := ApplyTransaction(b.config, bc, &b.header.Coinbase, b.gasPool, b.pubStateDB, b.privStateDB, remoteDB, |
| 101 | b.header, tx, &b.header.GasUsed, vm.Config{}, nil) // Account manager is not required in thes scenario. |
| 102 | if err != nil { |
| 103 | panic(err) |
| 104 | } |
| 105 | b.txs = append(b.txs, tx) |
| 106 | b.receipts = append(b.receipts, receipt) |
| 107 | } |
| 108 | |
| 109 | // Number returns the block number of the block being generated. |
| 110 | func (b *BlockGen) Number() *big.Int { |
no test coverage detected