MCPcopy Create free account
hub / github.com/CPChain/chain / AddTxWithChain

Method AddTxWithChain

core/chain_makers.go:89–107  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

87// added. If contract code relies on the BLOCKHASH instruction,
88// the block in chain will be returned.
89func (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.
110func (b *BlockGen) Number() *big.Int {

Callers 2

AddTxMethod · 0.95
SendTransactionMethod · 0.80

Calls 4

SetCoinbaseMethod · 0.95
ApplyTransactionFunction · 0.85
PrepareMethod · 0.80
HashMethod · 0.65

Tested by

no test coverage detected