.. versionadded:: 2014.1.0

    Check for the existence of a chain in the table

    CLI Example:

    .. code-block:: bash

        salt '*' iptables.check_chain filter INPUT

        IPv6:
        salt '*' iptables.check_chain filter INPUT family=ipv6
491363
def check_chain(table='filter', chain=None, family='ipv4'):
    '''
    
    '''

    if not chain:
        return 'Error: Chain needs to be specified'

    cmd = '{0}-save -t {1}'.format(_iptables_cmd(family), table)
    out = __salt__['cmd.run'](cmd).find(':{0} '.format(chain))

    if out != -1:
        out = True
    else:
        out = False

    return out
698586
def get_policy(table='filter', chain=None, family='ipv4'):
    '''
    
    '''
    if not chain:
        return 'Error: Chain needs to be specified'

    rules = _parse_conf(in_mem=True, family=family)
    try:
        return rules[table][chain]['policy']
    except KeyError:
        return None
1114526
@Override
    public void doFilter(ServletRequest req, ServletResponse resp, final FilterChain chain) throws IOException,
        ServletException {

        if (manager == null || isHttpRequest(req, resp)) {
            doFilterHttp((HttpServletRequest) req, (HttpServletResponse) resp, chain);
        } else {
            chain.doFilter(req, resp);
        }
    }
1035578
def exists(*nictag, **kwargs):
    '''
    
    '''
    ret = {}
    if not nictag:
        return {'Error': 'Please provide at least one nictag to check.'}

    cmd = 'nictagadm exists -l {0}'.format(' '.join(nictag))
    res = __salt__['cmd.run_all'](cmd)

    if not kwargs.get('verbose', False):
        ret = res['retcode'] == 0
    else:
        missing = res['stderr'].splitlines()
        for nt in nictag:
            ret[nt] = nt not in missing

    return ret
321655
def save(filename=None, family='ipv4'):
    '''
    
    '''
    if _conf() and not filename:
        filename = _conf(family)

    log.debug('Saving rules to %s', filename)

    parent_dir = os.path.dirname(filename)
    if not os.path.isdir(parent_dir):
        os.makedirs(parent_dir)
    cmd = '{0}-save'.format(_iptables_cmd(family))
    ipt = __salt__['cmd.run'](cmd)

    # regex out the output if configured with filters
    if _conf_save_filters():
        ipt = _regex_iptables_save(ipt)

    out = __salt__['file.write'](filename, ipt)
    return out
240115
def apply_fixture_block_to_chain(
        block_fixture: Dict[str, Any],
        chain: BaseChain,
        perform_validation: bool=True) -> Tuple[BaseBlock, BaseBlock, BaseBlock]:
    
    # The block to import may be in a different block-class-range than the
    # chain's current one, so we use the block number specified in the
    # fixture to look up the correct block class.
    if 'blockHeader' in block_fixture:
        block_number = block_fixture['blockHeader']['number']
        block_class = chain.get_vm_class_for_block_number(block_number).get_block_class()
    else:
        block_class = chain.get_vm().get_block_class()

    block = rlp.decode(block_fixture['rlp'], sedes=block_class)

    mined_block, _, _ = chain.import_block(block, perform_validation=perform_validation)

    rlp_encoded_mined_block = rlp.encode(mined_block, sedes=block_class)

    return (block, mined_block, rlp_encoded_mined_block)
68165
function(chain_id) {

        let i, len, network, network_name, ref;
        ref = Object.keys(_this.networks);

        for (i = 0, len = ref.length; i < len; i++) {

            network_name = ref[i];
            network = _this.networks[network_name];

            if (network.chain_id === chain_id) {

                _this.network_name = network_name;

                if (network.address_prefix) {
                    _this.address_prefix = network.address_prefix;
                    ecc_config.address_prefix = network.address_prefix;
                }

                // console.log("INFO    Configured for", network_name, ":", network.core_asset, "\n");

                return {
                    network_name: network_name,
                    network: network
                }
            }
        }

        if (!_this.network_name) {
            console.log("Unknown chain id (this may be a testnet)", chain_id);
        }

    }
1080702
def query_exists(filters):
        
        return db.session.query(
            KnwKB.query.filter(
                filters).exists()).scalar()
364152
def ip_fqdn():
    '''
    
    '''
    if salt.utils.platform.is_proxy():
        return {}

    ret = {}
    ret['ipv4'] = salt.utils.network.ip_addrs(include_loopback=True)
    ret['ipv6'] = salt.utils.network.ip_addrs6(include_loopback=True)

    _fqdn = hostname()['fqdn']
    for socket_type, ipv_num in ((socket.AF_INET, '4'), (socket.AF_INET6, '6')):
        key = 'fqdn_ip' + ipv_num
        if not ret['ipv' + ipv_num]:
            ret[key] = []
        else:
            try:
                start_time = datetime.datetime.utcnow()
                info = socket.getaddrinfo(_fqdn, None, socket_type)
                ret[key] = list(set(item[4][0] for item in info))
            except socket.error:
                timediff = datetime.datetime.utcnow() - start_time
                if timediff.seconds > 5 and __opts__['__role'] == 'master':
                    log.warning(
                        'Unable to find IPv%s record for "%s" causing a %s '
                        'second timeout when rendering grains. Set the dns or '
                        '/etc/hosts for IPv%s to clear this.',
                        ipv_num, _fqdn, timediff, ipv_num
                    )
                ret[key] = []

    return ret
129880
def set_policy(table='filter', chain=None, policy=None, family='ipv4'):
    '''
    
    '''
    if not chain:
        return 'Error: Chain needs to be specified'
    if not policy:
        return 'Error: Policy needs to be specified'

    wait = '--wait' if _has_option('--wait', family) else ''
    cmd = '{0} {1} -t {2} -P {3} {4}'.format(
            _iptables_cmd(family), wait, table, chain, policy)
    out = __salt__['cmd.run'](cmd)
    return out
504222
def block_verify( cls, verified_block_header, block_txids ):
        

        block_data = {
            'merkleroot': verified_block_header['merkleroot'],
            'tx': block_txids
        }

        return bits.block_verify( block_data )
1080034
def getTransactionByBlock(self, block_identifier, transaction_index):
        
        method = select_method_for_block_identifier(
            block_identifier,
            if_predefined='eth_getTransactionByBlockNumberAndIndex',
            if_hash='eth_getTransactionByBlockHashAndIndex',
            if_number='eth_getTransactionByBlockNumberAndIndex',
        )
        result = self.web3.manager.request_blocking(
            method,
            [block_identifier, transaction_index],
        )
        if result is None:
            raise TransactionNotFound(
                f"Transaction index: {transaction_index} "
                f"on block id: {block_identifier} not found."
            )
        return result
189257
def verify_input_sig_for_legacy(input_index, script_pubkey, flags)
      script_sig = inputs[input_index].script_sig
      checker = Bitcoin::TxChecker.new(tx: self, input_index: input_index)
      interpreter = Bitcoin::ScriptInterpreter.new(checker: checker, flags: flags)

      interpreter.verify_script(script_sig, script_pubkey)
    end
1064095
function chain(...fn) {
  return (...args) => fn.filter(i => !!i).forEach(i => i(...args));
}
1304385
def _sanity_check_query_root_block(ir_blocks):
    """"""
    if not isinstance(ir_blocks[0], QueryRoot):
        raise AssertionError(u'The first block was not QueryRoot: {}'.format(ir_blocks))
    for block in ir_blocks[1:]:
        if isinstance(block, QueryRoot):
            raise AssertionError(u'Found QueryRoot after the first block: {}'.format(ir_blocks))
1235730
def list_rules(self, chainname):
        
        data = self.__run([self.__iptables_save, '-t', self.__name, '-c'])
        return netfilter.parser.parse_rules(data, chainname)
243531
def has(self, block, name):
        
        try:
            return self._kvs.has(self._key(block, name))
        except KeyError:
            return False