Example #1
0
 def _setup_benchmark(self, chain: MiningChain) -> None:
     self._next_nonce = None
     txn, callback = self._deploy_simple_token(chain)
     _, receipts, computations = chain.mine_all([txn])
     assert len(receipts) == 1
     assert len(computations) == 1
     callback(receipts[0], computations[0])
Example #2
0
    def _setup_benchmark(self, chain: MiningChain) -> None:
        self._next_nonce = None
        txn, callback = self._deploy_simple_token(chain)
        _, receipts, computations = chain.mine_all([txn])
        assert len(receipts) == 1
        assert len(computations) == 1
        callback(receipts[0], computations[0])

        actions = [
            self._erc_transfer(self.addr1, chain, nonce=1),
            self._erc_approve(self.addr2, chain, nonce=2),
        ]
        transactions, callbacks = zip(*actions)
        _, receipts, computations = chain.mine_all(transactions)

        for callback, receipt, computation in zip(callbacks, receipts,
                                                  computations):
            callback(receipt, computation)
Example #3
0
    def mine_block(self, chain: MiningChain, block_number: int,
                   num_tx: int) -> BaseBlock:
        transactions, callbacks = zip(*(self._next_transaction(chain)
                                        for _ in range(num_tx)))

        mining_result, receipts, computations = chain.mine_all(transactions)

        for callback, receipt, computation in zip(callbacks, receipts,
                                                  computations):
            callback(receipt, computation)

        return mining_result