Return the state of settling channels in a token network.
421211
def get_channelstate_settling(
        chain_state: ChainState,
        payment_network_id: PaymentNetworkID,
        token_address: TokenAddress,
) -> List[NettingChannelState]:
    """"""
    return get_channelstate_filter(
        chain_state,
        payment_network_id,
        token_address,
        lambda channel_state: channel.get_status(channel_state) == CHANNEL_STATE_SETTLING,
    )
719919
def _get_channel_state_statelessly(self, grpc_channel, channel_id):
        
        server     = self._get_channel_state_from_server    (grpc_channel, channel_id)
        blockchain = self._get_channel_state_from_blockchain(              channel_id)

        if (server["current_nonce"] == blockchain["nonce"]):
            unspent_amount = blockchain["value"] - server["current_signed_amount"]
        else:
            unspent_amount = None # in this case we cannot securely define unspent_amount yet

        return (server["current_nonce"], server["current_signed_amount"], unspent_amount)
381264
def status(self):
        ''''''
        transfered = self.download - self.prev_download
        now = time.time()
        interval = now - self.last_status_time
        self.last_status_time = now
        return("DFLogger: %(state)s Rate(%(interval)ds):%(rate).3fkB/s Block:%(block_cnt)d Missing:%(missing)d Fixed:%(fixed)d Abandoned:%(abandoned)d" %
              {"interval": interval,
               "rate": transfered/(interval*1000),
               "block_cnt": self.block_cnt,
               "missing": len(self.missing_blocks),
               "fixed": self.missing_found,
               "abandoned": self.abandoned,
               "state": "Inactive" if self.stopped else "Active"
           })
571182
def _generate_next_token_helper(self, past_states, transitions):
        
        key = tuple(past_states)
        assert key in transitions, "%s" % str(key)
        return utils.weighted_choice(transitions[key].items())
182993
def get_slack_channels(self, token):
        '''
        
        '''

        ret = salt.utils.slack.query(
            function='rooms',
            api_key=token,
            # These won't be honored until https://github.com/saltstack/salt/pull/41187/files is merged
            opts={
                'exclude_archived': True,
                'exclude_members': True
            })
        channels = {}
        if 'message' in ret:
            for item in ret['message']:
                channels[item['id']] = item['name']
        return channels
13943
def states(self):
        
        return frozenset(
            chain.from_iterable(
                (inState, outState)
                for
                (inState, inputSymbol, outState, outputSymbol)
                in self._transitions
            )
        )
463787
def opened(self, block_identifier: BlockSpecification) -> bool:
        
        return self.token_network.channel_is_opened(
            participant1=self.participant1,
            participant2=self.participant2,
            block_identifier=block_identifier,
            channel_identifier=self.channel_identifier,
        )
795279
def nfa(self):
        """"""
        finalstate = State(final=True)
        nextstate = finalstate
        for tokenexpr in reversed(self):
            state = tokenexpr.nfa(nextstate)
            nextstate = state
        return NFA(state)
382451
def get_channel_info(self):
        """"""
        self.request(EP_GET_CHANNEL_INFO)
        return {} if self.last_response is None else self.last_response.get('payload')
1110405
def wait_for_settle(
        raiden: 'RaidenService',
        payment_network_id: PaymentNetworkID,
        token_address: TokenAddress,
        channel_ids: List[ChannelID],
        retry_timeout: float,
) -> None:
    
    return wait_for_channel_in_states(
        raiden=raiden,
        payment_network_id=payment_network_id,
        token_address=token_address,
        channel_ids=channel_ids,
        retry_timeout=retry_timeout,
        target_states=(CHANNEL_STATE_SETTLED,),
    )
102559
def close(
            self,
            nonce: Nonce,
            balance_hash: BalanceHash,
            additional_hash: AdditionalHash,
            signature: Signature,
            block_identifier: BlockSpecification,
    ):
        
        self.token_network.close(
            channel_identifier=self.channel_identifier,
            partner=self.participant2,
            balance_hash=balance_hash,
            nonce=nonce,
            additional_hash=additional_hash,
            signature=signature,
            given_block_identifier=block_identifier,
        )
631859
def getResiduals(self):
        
        X = np.zeros((self.N*self.P,self.n_fixed_effs))
        ip = 0
        for i in range(self.n_terms):
            Ki = self.A[i].shape[0]*self.F[i].shape[1]
            X[:,ip:ip+Ki] = np.kron(self.A[i].T,self.F[i])
            ip += Ki
        y = np.reshape(self.Y,(self.Y.size,1),order='F')
        RV = regressOut(y,X)
        RV = np.reshape(RV,self.Y.shape,order='F')
        return RV
1332360
def get_service_node_state(self, state, problem_has_been_acknowledged, in_scheduled_downtime):
        
        # If our node is acknowledged or in downtime, state is ok/up
        if problem_has_been_acknowledged or in_scheduled_downtime:
            state = 0

        # Maybe we are a NOT node, so manage this
        if self.not_value:
            # Critical -> OK
            if state == 2:
                return 0
            # OK -> CRITICAL (warning is untouched)
            if state == 0:
                return 2
        return state
913638
def _refresh_channel(self):
        '''
        
        '''
        self.channel = salt.transport.client.ReqChannel.factory(self.opts)
        return self.channel
31241
@SuppressWarnings("ReferenceEquality")
  private void updateBalancingState() {
    List<Subchannel> activeList = filterNonFailingSubchannels(getSubchannels());
    if (activeList.isEmpty()) {
      // No READY subchannels, determine aggregate state and error status
      boolean isConnecting = false;
      Status aggStatus = EMPTY_OK;
      for (Subchannel subchannel : getSubchannels()) {
        ConnectivityStateInfo stateInfo = getSubchannelStateInfoRef(subchannel).value;
        // This subchannel IDLE is not because of channel IDLE_TIMEOUT,
        // in which case LB is already shutdown.
        // RRLB will request connection immediately on subchannel IDLE.
        if (stateInfo.getState() == CONNECTING || stateInfo.getState() == IDLE) {
          isConnecting = true;
        }
        if (aggStatus == EMPTY_OK || !aggStatus.isOk()) {
          aggStatus = stateInfo.getStatus();
        }
      }
      updateBalancingState(isConnecting ? CONNECTING : TRANSIENT_FAILURE,
          // If all subchannels are TRANSIENT_FAILURE, return the Status associated with
          // an arbitrary subchannel, otherwise return OK.
          new EmptyPicker(aggStatus));
    } else {
      // initialize the Picker to a random start index to ensure that a high frequency of Picker
      // churn does not skew subchannel selection.
      int startIndex = random.nextInt(activeList.size());
      updateBalancingState(READY, new ReadyPicker(activeList, startIndex, stickinessState));
    }
  }
1179756
def to_dict(self) -> Dict[str, Any]:
        """"""
        return {
            'type': self.__class__.__name__,
            'channel_identifier': self.channel_identifier,
            'token_network_address': to_normalized_address(self.token_network_address),
            'balance_hash': encode_hex(self.balance_hash),
            'nonce': self.nonce,
            'additional_hash': encode_hex(self.additional_hash),
            'signature': encode_hex(self.signature),
            'chain_id': self.chain_id,
        }
221694
def _claim_in_progress_and_claim_channels(self, grpc_channel, channels):
        
        # first we get the list of all 'payments in progress' in case we 'lost' some payments.
        payments = self._call_GetListInProgress(grpc_channel)
        if (len(payments) > 0):
            self._printout("There are %i payments in 'progress' (they haven't been claimed in blockchain). We will claim them."%len(payments))
            self._blockchain_claim(payments)
        payments = self._start_claim_channels(grpc_channel, channels)
        self._blockchain_claim(payments)