def create_block_with_nonce( parent_hash=default_config["GENESIS_PREVHASH"], height=0, timestamp=None, difficulty=TEST_DIFFICULTY, transactions=[], gas_limit=3000000000, referee_hashes=[], author=default_config["GENESIS_COINBASE"], deferred_state_root=default_config["GENESIS_STATE_ROOT"], deferred_receipts_root=default_config["GENESIS_RECEIPTS_ROOT"], deferred_logs_bloom_hash=default_config["GENESIS_LOGS_BLOOM_HASH"], adaptive=0, nonce=0): if timestamp is None: timestamp = int(time.time()) tx_root = utils.sha3(rlp.encode(Transactions(transactions))) header = BlockHeader(parent_hash=parent_hash, height=height, difficulty=difficulty, timestamp=timestamp, author=author, transactions_root=tx_root, gas_limit=gas_limit, referee_hashes=referee_hashes, nonce=nonce, deferred_state_root=deferred_state_root, deferred_receipts_root=deferred_receipts_root, deferred_logs_bloom_hash=deferred_logs_bloom_hash, adaptive=adaptive) block = Block(block_header=header, transactions=transactions) return block
def create_block( parent_hash=default_config["GENESIS_PREVHASH"], height=0, timestamp=None, difficulty=TEST_DIFFICULTY, transactions=[], gas_limit=3000000000, referee_hashes=[], author=default_config["GENESIS_COINBASE"], deferred_state_root=default_config["GENESIS_STATE_ROOT"], deferred_receipts_root=default_config["GENESIS_RECEIPTS_ROOT"], adaptive=0): if timestamp is None: timestamp = int(time.time()) tx_root = utils.sha3(rlp.encode(Transactions(transactions))) nonce = 0 while True: header = BlockHeader(parent_hash=parent_hash, height=height, difficulty=difficulty, timestamp=timestamp, author=author, transactions_root=tx_root, gas_limit=gas_limit, referee_hashes=referee_hashes, nonce=nonce, deferred_state_root=deferred_state_root, deferred_receipts_root=deferred_receipts_root, adaptive=adaptive) if header.pow_decimal() * difficulty < HASH_MAX: break nonce += 1 block = Block(block_header=header, transactions=transactions) return block
def create_block( parent_hash=default_config["GENESIS_PREVHASH"], height=0, timestamp=None, difficulty=TEST_DIFFICULTY, gas_limit=default_config["GENESIS_GAS_LIMIT"], referee_hashes=[], author=default_config["GENESIS_COINBASE"], deferred_state_root=default_config["GENESIS_STATE_ROOT"], deferred_receipts_root=trie. EMPTY_EPOCH_RECEIPT_ROOT_BY_NUMBER_OF_BLOCKS[0], deferred_logs_bloom_hash=default_config["GENESIS_LOGS_BLOOM_HASH"], adaptive=0, transaction_root=None, transactions=None, pos_reference=[default_config["POS_GENESIS_BLOCK"]]): if timestamp is None: timestamp = int(time.time()) if transaction_root is None: # So far we can not compute the transaction root in python, # therefore we don't support filling in transactions without providing transaction root. assert transactions is None transaction_root = trie.NULL_ROOT transactions = [] nonce = 0 while True: header = BlockHeader(parent_hash=parent_hash, height=height, difficulty=difficulty, timestamp=timestamp, author=author, transactions_root=transaction_root, gas_limit=gas_limit, referee_hashes=referee_hashes, nonce=nonce, deferred_state_root=deferred_state_root, deferred_receipts_root=deferred_receipts_root, deferred_logs_bloom_hash=deferred_logs_bloom_hash, adaptive=adaptive, pos_reference=pos_reference) if header.pow_decimal() * difficulty < HASH_MAX: break nonce += 1 block = Block(block_header=header, transactions=transactions) return block