示例#1
0
def process_transactions(data_db,
                         block_height,
                         pubkeyhash_version,
                         checksum_value,
                         client=None):
    if client == None:
        client = get_active_rpc_client()

    try:
        block = client.getblock('{}'.format(block_height), 4)
    except Exception as e:
        log.debug(e)
        return

    for pos_in_block, tx in enumerate(block['tx']):
        try:
            tx_relevant = process_inputs_and_outputs(data_db, tx,
                                                     pubkeyhash_version,
                                                     checksum_value)

        except Exception as e:
            log.debug(e)
            return

        # add only relevant TXs to the database.
        if tx_relevant:
            Transaction.create_if_not_exists(
                data_db,
                Transaction(txid=tx['txid'],
                            pos_in_block=pos_in_block,
                            block=unhexlify(block['hash'])))