def mine(): # config object conf = Configuration() # Mines block reward_address = conf.get_conf("wallet").get("address") reward_amount = conf.get_conf("reward") size = 0 # TODO: fix this # 2) bundle transactions tnx = bundle_tnx(size, reward_amount) b = Block(previous_hash=conf.get_conf("last_block"), transactions=tnx) b.set_target(conf.get_conf("difficulty")) b.mine() save_block(b) conf.increment_height() conf.update_previous_hash(b.block_hash()) find_incoming_utxos(b.block_hash(), b.transactions)
def get_block(block_hash): """ Gets a block :param block_hash: the block hash :return: block """ if block_hash == '': conf = Configuration() block_hash = conf.get_conf("last_block") return read_block(block_hash)
def init_configuration(): """ This will instantiate the config class and check if genesis block is created :return: configuration object """ conf = Configuration() block_height = conf.get_conf("height") if block_height == 0: b = genesis_block() cwd = os.getcwd() try: os.makedirs(os.path.join(cwd, r'data')) except OSError as e: pass save_block(b) conf.increment_height() conf.update_previous_hash(b.block_hash()) find_incoming_utxos(b.block_hash(), b.transactions, True) return conf