Get the list of virtualchain transactions accepted at a given block.
        Returns the list of rows, where each row is a dict.
16931
def db_chainstate_get_block(cls, cur, block_height):
        
        query = 'SELECT * FROM chainstate WHERE block_id = ? ORDER BY vtxindex;'
        args = (block_height,)

        rows = cls.db_query_execute(cur, query, args, verbose=False)
        ret = []

        for r in rows:
            rowdata = {
                'txid': str(r['txid']),
                'block_id': r['block_id'],
                'txindex': r['txindex'],
                'vtxindex': r['vtxindex'],
                'opcode': str(r['opcode']),
                'data_hex': str(r['data_hex']),
                'senders': simplejson.loads(r['senders']),
                'tx_hex': str(r['tx_hex']),
                'tx_merkle_path': str(r['tx_merkle_path']),
                'fee': r['fee']
            }

            ret.append(rowdata)

        return ret
839941
def list_dvs(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The list_dvs function must be called with '
            '-f or --function.'
        )

    return {'Distributed Virtual Switches': salt.utils.vmware.list_dvs(_get_si())}
570767
def get_catchup_block_ids(self, last_known_block_id):
        '''
        
        '''
        # If latest known block is not the current chain head, catch up
        catchup_up_blocks = []
        chain_head = self._block_store.chain_head
        if chain_head and last_known_block_id != chain_head.identifier:
            # Start from the chain head and get blocks until we reach the
            # known block
            for block in self._block_store.get_predecessor_iter():
                # All the blocks if NULL_BLOCK_IDENTIFIER
                if last_known_block_id != NULL_BLOCK_IDENTIFIER:
                    if block.identifier == last_known_block_id:
                        break
                catchup_up_blocks.append(block.identifier)

        return list(reversed(catchup_up_blocks))
878904
def get_transaction_result(
            self,
            transaction: BaseOrSpoofTransaction,
            at_header: BlockHeader) -> bytes:
        
        with self.get_vm(at_header).state_in_temp_block() as state:
            computation = state.costless_execute_transaction(transaction)

        computation.raise_if_error()
        return computation.output
515710
def ToJson(self):
        
        json = super(Block, self).ToJson()
        if self.Transactions[0] and isinstance(self.Transactions[0], str):
            json['tx'] = ['0x%s' % tx for tx in self.Transactions]
        else:
            json['tx'] = [tx.ToJson() for tx in self.Transactions]

        # json['sys_fee'] = GetBlockchain().GetSysFeeAmount(self.Hash)
        return json
979161
def get_consensus(block):
    """"""
    from collections import Counter

    # Take aligned (non-insert) chars from all rows; transpose
    columns = zip(*[[c for c in row['seq'] if not c.islower()]
                    for row in block['sequences']])
    cons_chars = [Counter(col).most_common()[0][0] for col in columns]
    cons_chars = [c if c != '-' else 'X' for c in cons_chars]
    assert len(cons_chars) == block['query_length']
    cons_sequence = {
        'index': 1,
        'id': 'consensus',
        'description': '',
        'dbxrefs': {},
        'phylum': '',
        'taxchar': '',
        'head_len': None,
        'tail_len': None,
        'head_seq': '',
        'tail_seq': '',
        'length': block['query_length'],
        'seq': ''.join(cons_chars),
    }
    return cons_sequence
1059211
def namedb_get_num_block_vtxs( cur, block_number ):
     
    select_query = "SELECT vtxindex FROM history WHERE history_id = ?;"
    args = (block_number,)

    rows = namedb_query_execute( cur, select_query, args )
    count = 0
    for r in rows:
        count += 1

    return count
1320424
def get_blocks_overview(block_representation_list, coin_symbol='btc', txn_limit=None, api_key=None):
    '''
    
    '''
    for block_representation in block_representation_list:
        assert is_valid_block_representation(
                block_representation=block_representation,
                coin_symbol=coin_symbol)
    assert is_valid_coin_symbol(coin_symbol)

    blocks = ';'.join([str(x) for x in block_representation_list])
    url = make_url(coin_symbol, **dict(blocks=blocks))

    logger.info(url)

    params = {}
    if api_key:
        params['token'] = api_key
    if txn_limit:
        params['limit'] = txn_limit

    r = requests.get(url, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS)
    r = get_valid_json(r)
    return [_clean_tx(response_dict=d) for d in r]
1187181
def _build_block_element_list(self):
        
        return sorted(
            [e for e in self.block_elements.values() if not e.virtual],
            key=lambda e: e.priority,
            reverse=True
        )
847382
def operations(self):
        
        return [op for block in self.blocks for op in block.vex.operations]
520397
def list(self):
        
        params = {'user': self.user_id}
        response = self.session.get(self.url, params=params)
        blocks = response.data['blocks']
        return [Block(self, **block) for block in blocks]
659771
def list_blocks_of_type(self, blocktype, size):
        """"""

        blocktype = snap7.snap7types.block_types.get(blocktype)

        if not blocktype:
            raise Snap7Exception("The blocktype parameter was invalid")

        logger.debug("listing blocks of type: %s size: %s" %
                      (blocktype, size))

        if (size == 0):
            return 0
		
        data = (c_uint16 * size)()
        count = c_int(size)
        result = self.library.Cli_ListBlocksOfType(
            self.pointer, blocktype,
            byref(data),
            byref(count))

        logger.debug("number of items found: %s" % count)

        check_error(result, context="client")
        return data
363047
def rpc_get_consensus_hashes( self, block_id_list, **con_info ):
        
        if type(block_id_list) != list:
            return {'error': 'Invalid block heights', 'http_status': 400}

        if len(block_id_list) > 32:
            return {'error': 'Too many block heights', 'http_status': 400}

        for bid in block_id_list:
            if not check_block(bid):
                return {'error': 'Invalid block height', 'http_status': 400}

        db = get_db_state(self.working_dir)
        ret = {}
        for block_id in block_id_list:
            ret[block_id] = db.get_consensus_at(block_id)

        db.close()

        return self.success_response( {'consensus_hashes': ret} )
163660
def getBlocks(self):
        
        try:
            conn = self.dbi.connection()
            result = self.buflistblks.execute(conn)
            return result
        finally:
            if conn:
                conn.close()
453686
def snv_get_blockstack_ops_at(current_block_id, current_consensus_hash, block_id, consensus_hash, proxy=None):
    
    import blockstack

    log.debug('verify {}-{} to {}-{}'.format(
        current_block_id, current_consensus_hash, block_id, consensus_hash
    ))

    proxy = get_default_proxy() if proxy is None else proxy

    # work backwards in time, using a Merkle skip-list constructed
    # by blockstackd over the set of consensus hashes.
    next_block_id = current_block_id

    prev_blockstack_ops_hashes = {}
    prev_consensus_hashes = {
        next_block_id: current_consensus_hash
    }

    # print 'next_block_id = {}, block_id = {}'.format(next_block_id, block_id)
    while next_block_id >= block_id:
        # get blockstack_ops_at[ next_block_id ], and all consensus_hash[ next_block_id - 2^i ]
        # such that block_id - 2*i > block_id (start at i = 1)
        i = 0
        blockstack_ops_hash = None

        if next_block_id in prev_blockstack_ops_hashes:
            blockstack_ops_hash = prev_blockstack_ops_hashes[next_block_id]
        else:
            blockstack_ops_resp = get_blockstack_ops_hash_at(next_block_id, proxy=proxy)

            if 'error' in blockstack_ops_resp:
                log.error('get_blockstack_ops_hash_at: {}'.format(blockstack_ops_resp['error']))
                return {'error': 'Failed to get nameops: {}'.format(blockstack_ops_resp['error'])}

            blockstack_ops_hash = str(blockstack_ops_resp)
            prev_blockstack_ops_hashes[next_block_id] = blockstack_ops_hash

        log.debug('nameops hash at {}: {}'.format(next_block_id, blockstack_ops_hash))

        # find out which consensus hashes we'll need
        to_fetch = []
        ch_block_ids = []
        while next_block_id - (2 ** (i + 1) - 1) >= FIRST_BLOCK_MAINNET:
            i += 1
            prev_block_id = next_block_id - (2 ** i - 1)
            ch_block_ids.append(prev_block_id)

            if prev_block_id not in prev_consensus_hashes:
                to_fetch.append(prev_block_id)

        # get the consensus hashes
        chs = {}
        if to_fetch:
            chs = get_consensus_hashes(to_fetch, proxy=proxy)
            if 'error' in chs:
                msg = 'Failed to get consensus hashes for {}: {}'
                log.error(msg.format(to_fetch, chs['error']))
                return {'error': 'Failed to get consensus hashes'}

        prev_consensus_block_ids = []
        for b in ch_block_ids:
            # NOTE: we process to_fetch *in decreasing order* so we know when we're missing data
            if b not in chs and b not in prev_consensus_hashes:
                msg = 'Missing consensus hash response for {} (chs={}, prev_chs={})'
                log.error(msg.format(b, chs, prev_consensus_hashes))
                return {'error': 'Server did not reply valid data'}

            prev_consensus_block_ids.append(b)
            if b in prev_consensus_hashes:
                # already got this one
                continue

            ch = chs[b]
            if ch is not None:
                prev_consensus_hashes[b] = str(ch)
            else:
                # no consensus hash for this block and all future blocks
                prev_consensus_block_ids.pop()
                break

        # prev_consensus_hashes_list = [ prev_consensus_hashes[b] for b in ch_block_ids ]
        prev_consensus_hashes_list = [
            prev_consensus_hashes[b] for b in prev_consensus_block_ids
        ]

        # calculate the snapshot, and see if it matches
        ch = virtualchain.StateEngine.make_snapshot_from_ops_hash(
            blockstack_ops_hash, prev_consensus_hashes_list
        )

        expected_ch = prev_consensus_hashes[next_block_id]
        if ch != expected_ch:
            msg = 'Consensus hash mismatch at {}: expected {}, got {} (from {}, {})'
            log.error(msg.format(next_block_id, expected_ch, ch, blockstack_ops_hash, prev_consensus_hashes))
            return {'error': 'Consensus hash mismatch'}

        # advance!
        # find the smallest known consensus hash whose block is greater than block_id
        current_candidate = next_block_id
        found_any = False
        for candidate_block_id in prev_consensus_hashes:
            if candidate_block_id < block_id:
                continue

            if candidate_block_id < current_candidate:
                current_candidate = candidate_block_id
                found_any = True

        if not found_any:
            break

        next_block_id = current_candidate

    # get the final nameops
    historic_nameops = get_blockstack_transactions_at(block_id, proxy=proxy)
    if isinstance(historic_nameops, dict) and 'error' in historic_nameops:
        log.error('Failed to get nameops at {}: {}'.format(block_id, historic_nameops['error']))
        return {'error': 'BUG: no nameops found'}

    log.debug("nameops at {}\n{}".format(block_id, json.dumps(historic_nameops, sort_keys=True)))

    # sanity check...
    for historic_op in historic_nameops:
        if 'opcode' not in historic_op:
            return {'error': 'Invalid/corrupt name operations detected'}

        # recover binary op string
        if 'op' not in historic_op:
            historic_op['op'] = NAME_OPCODES[str(historic_op['opcode'])]

    # check integrity
    opfields = blockstack.lib.virtualchain_hooks.get_opfields()
    serialized_historic_nameops = [
        virtualchain.StateEngine.serialize_op(
            str(op['op'][0]), op, opfields, verbose=True
        ) for op in historic_nameops
    ]

    historic_blockstack_ops_hash = virtualchain.StateEngine.make_ops_snapshot(serialized_historic_nameops)

    if block_id not in prev_blockstack_ops_hashes:
        return {'error': 'Previous block/consensus hash is unreachable from trusted block/consensus hash'}

    if historic_blockstack_ops_hash != prev_blockstack_ops_hashes[block_id]:
        log.error("historic nameops hash at {}: {}".format(block_id, historic_blockstack_ops_hash))
        log.error("prev_blockstack_ops_hashes:\n{}".format(json.dumps(prev_blockstack_ops_hashes, indent=4, sort_keys=True)))
        return {
            'error': 'Hash mismatch: failed to get operations at {}-{} from {}-{} ({} != {})'.format(
                block_id, consensus_hash, current_block_id, current_consensus_hash, historic_blockstack_ops_hash, prev_blockstack_ops_hashes[block_id]
            )
        }

    log.debug('{} nameops at {}'.format(len(historic_nameops), block_id))

    # strip history
    for hn in historic_nameops:
        if 'history' in hn.keys():
            del hn['history']

    return historic_nameops
158747
def get_transaction(txhash)
      blockhash, tx_num_enc = RLP.decode @db.get(txhash)
      blk = RLP.decode(@db.get(blockhash), sedes: Block, env: @env)

      num = Utils.decode_int tx_num_enc
      tx_data = blk.get_transaction num

      [tx_data, blk, num]
    end
847324
def list_blocks(self):
        
        logger.debug("listing blocks")
        blocksList = BlocksList()
        result = self.library.Cli_ListBlocks(self.pointer, byref(blocksList))
        check_error(result, context="client")
        logger.debug("blocks: %s" % blocksList)
        return blocksList