Checks ledger config txns and perfomes recent one

        :return:
513752
def processLedger(self) -> None:
        
        logger.debug('{} processing config ledger for any POOL_CONFIGs'.format(
            self), extra={"tags": ["pool-config"]})
        for _, txn in self.ledger.getAllTxn():
            if get_type(txn) == POOL_CONFIG:
                self.handleConfigTxn(txn)
223263
def check_signature(self, timestamp, nonce, signature):
        
        return check_signature(
            self.config["TOKEN"], timestamp, nonce, signature
        )
575262
def create_3pc_batch(self, ledger_id):
        pp_seq_no = self.lastPrePrepareSeqNo + 1
        pool_state_root_hash = self.stateRootHash(POOL_LEDGER_ID)
        self.logger.debug("{} creating batch {} for ledger {} with state root {}".format(
            self, pp_seq_no, ledger_id,
            self.stateRootHash(ledger_id, to_str=False)))

        if self.last_accepted_pre_prepare_time is None:
            last_ordered_ts = self._get_last_timestamp_from_state(ledger_id)
            if last_ordered_ts:
                self.last_accepted_pre_prepare_time = last_ordered_ts

        # DO NOT REMOVE `view_no` argument, used while replay
        # tm = self.utc_epoch
        tm = self.get_utc_epoch_for_preprepare(self.instId, self.viewNo,
                                               pp_seq_no)

        reqs, invalid_indices, rejects = self.consume_req_queue_for_pre_prepare(
            ledger_id, tm, self.viewNo, pp_seq_no)
        if self.isMaster:
            three_pc_batch = ThreePcBatch(ledger_id=ledger_id,
                                          inst_id=self.instId,
                                          view_no=self.viewNo,
                                          pp_seq_no=pp_seq_no,
                                          pp_time=tm,
                                          state_root=self.stateRootHash(ledger_id, to_str=False),
                                          txn_root=self.txnRootHash(ledger_id, to_str=False),
                                          primaries=[],
                                          valid_digests=self.get_valid_req_ids_from_all_requests(
                                              reqs, invalid_indices))
            self.node.onBatchCreated(three_pc_batch)

        digest = self.batchDigest(reqs)
        state_root_hash = self.stateRootHash(ledger_id)
        audit_txn_root_hash = self.txnRootHash(AUDIT_LEDGER_ID)

        """"""
        params = [
            self.instId,
            self.viewNo,
            pp_seq_no,
            tm,
            [req.digest for req in reqs],
            invalid_index_serializer.serialize(invalid_indices, toBytes=False),
            digest,
            ledger_id,
            state_root_hash,
            self.txnRootHash(ledger_id),
            0,
            True,
            pool_state_root_hash,
            audit_txn_root_hash
        ]

        # BLS multi-sig:
        params = self._bls_bft_replica.update_pre_prepare(params, ledger_id)

        pre_prepare = PrePrepare(*params)
        if self.isMaster:
            rv = self.execute_hook(ReplicaHooks.CREATE_PPR, pre_prepare)
            pre_prepare = rv if rv is not None else pre_prepare

        self.logger.trace('{} created a PRE-PREPARE with {} requests for ledger {}'.format(
            self, len(reqs), ledger_id))
        self.lastPrePrepareSeqNo = pp_seq_no
        self.last_accepted_pre_prepare_time = tm
        if self.isMaster:
            self.outBox.extend(rejects)
        return pre_prepare
507519
def _get_net_io_counters(self):
        
        counters = psutil.net_io_counters(pernic=self.pernic)

        res = {}
        for name, io in counters.iteritems():
            res[name] = io._asdict()
            res[name].update({'tx_per_sec': 0, 'rx_per_sec': 0})

        return res
1318255
def _has_valid_catchup_replies(self, seq_no: int, txns_to_process: List[Tuple[int, Any]]) -> Tuple[bool, str, int]:
        

        # TODO: Remove after stop passing seqNo here
        assert seq_no == txns_to_process[0][0]

        # Here seqNo has to be the seqNo of first transaction of
        # `catchupReplies`

        # Get the transactions in the catchup reply which has sequence
        # number `seqNo`
        node_name, catchup_rep = self._find_catchup_reply_for_seq_no(seq_no)
        txns = catchup_rep.txns

        # Add only those transaction in the temporary tree from the above
        # batch which are not present in the ledger
        # Integer keys being converted to strings when marshaled to JSON
        txns = [self._provider.transform_txn_for_ledger(txn)
                for s, txn in txns_to_process[:len(txns)]
                if str(s) in txns]

        # Creating a temporary tree which will be used to verify consistency
        # proof, by inserting transactions. Duplicating a merkle tree is not
        # expensive since we are using a compact merkle tree.
        temp_tree = self._ledger.treeWithAppliedTxns(txns)

        proof = catchup_rep.consProof
        final_size = self._catchup_till.final_size
        final_hash = self._catchup_till.final_hash
        try:
            logger.info("{} verifying proof for {}, {}, {}, {}, {}".
                        format(self, temp_tree.tree_size, final_size,
                               temp_tree.root_hash, final_hash, proof))
            verified = self._provider.verifier(self._ledger_id).verify_tree_consistency(
                temp_tree.tree_size,
                final_size,
                temp_tree.root_hash,
                Ledger.strToHash(final_hash),
                [Ledger.strToHash(p) for p in proof]
            )

        except Exception as ex:
            logger.info("{} could not verify catchup reply {} since {}".format(self, catchup_rep, ex))
            verified = False
        return bool(verified), node_name, len(txns)
863461
def init_state_from_ledger(self, state: State, ledger: Ledger, reqHandler):
        
        if state.isEmpty:
            logger.info('{} found state to be empty, recreating from '
                        'ledger'.format(self))
            for seq_no, txn in ledger.getAllTxn():
                txn = self.update_txn_with_extra_data(txn)
                reqHandler.updateState([txn, ], isCommitted=True)
                state.commit(rootHash=state.headHash)
1068526
def doDynamicValidation(self, request: Request):
        
        self.execute_hook(NodeHooks.PRE_DYNAMIC_VALIDATION, request=request)

        # Digest validation
        ledger_id, seq_no = self.seqNoDB.get_by_payload_digest(request.payload_digest)
        if ledger_id is not None and seq_no is not None:
            raise SuspiciousPrePrepare('Trying to order already ordered request')

        ledger = self.getLedger(self.ledger_id_for_request(request))
        for txn in ledger.uncommittedTxns:
            if get_payload_digest(txn) == request.payload_digest:
                raise SuspiciousPrePrepare('Trying to order already ordered request')

        operation = request.operation
        req_handler = self.get_req_handler(txn_type=operation[TXN_TYPE])
        req_handler.validate(request)

        self.execute_hook(NodeHooks.POST_DYNAMIC_VALIDATION, request=request)
860896
def _check(self):
        """"""
        import time

        if self.expires_in is None or self.authenticated is None:
            return False

        current = time.time()
        expire_time = self.authenticated + self.expires_in

        return expire_time > current
408187
def in_transaction(self):
        """"""
        if not hasattr(self.local, 'tx'):
            return False
        return len(self.local.tx) > 0
1353013
def handleConfigTxn(self, txn) -> None:
        
        if get_type(txn) == POOL_CONFIG:
            self.writes = get_payload_data(txn)[WRITES]
100463
def update_freshness(self, ledger_id, ts):
        '''
        
        '''
        if ledger_id in self._ledger_freshness:
            self._ledger_freshness[ledger_id].last_updated = ts
765187
private boolean checkTickerFreshness() {
		final QuoteManager quoteManager = bitfinexApiBroker.getQuoteManager();
		final Map<BitfinexStreamSymbol, Long> heartbeatValues = quoteManager.getLastTickerActivity();

		return checkTickerFreshness(heartbeatValues);
	}
649785
def usage() -> None:
    

    print()
    print('Usage: setnym.py <config-ini>')
    print()
    print('where <config-ini> represents the path to the configuration file.')
    print()
    print('The operation submits a nym to a trustee anchor to send to the ledger,')
    print('if the ledger does not have it already as configured.')
    print()
    print('The configuration file has sections and entries as follows:')
    print('  * section [Node Pool]:')
    print('    - name: the name of the node pool to which the operation applies')
    print('    - genesis.txn.path: the path to the genesis transaction file')
    print('        for the node pool (may omit if node pool already exists)')
    print('  * section [Trustee Anchor]:')
    print("    - name: the trustee anchor's (wallet) name")
    print("    - wallet.type: (default blank) the trustee anchor's wallet type")
    print("    - wallet.access: (default blank) the trustee anchor's")
    print('        wallet access credential (password) value')
    print('  * section [VON Anchor]:')
    print('    - role: the role to request in the send-nym transaction; specify:')
    print('        - (default) empty value for user with no additional write privileges')
    print('        - TRUST_ANCHOR for VON anchor with write privileges for indy artifacts')
    print('        - TRUSTEE for VON anchor sending further cryptonyms to the ledger')
    print("    - name: the VON anchor's (wallet) name")
    print("    - seed: the VON anchor's seed (optional, for wallet creation only)")
    print("    - did: the VON anchor's DID (optional, for wallet creation only)")
    print('    - wallet.create: whether create the wallet if it does not yet exist')
    print('        (value True/False, 1/0, or Yes/No)')
    print("    - wallet.type: (default blank) the VON anchor's wallet type")
    print("    - wallet.access: (default blank) the VON anchor's")
    print('        wallet access credential (password) value.')
    print()
791120
def transform_attrib_for_ledger(txn):
        
        txn = deepcopy(txn)
        txn_data = get_payload_data(txn)
        attr_type, _, value = domain.parse_attr_txn(txn_data)
        if attr_type in [RAW, ENC]:
            txn_data[attr_type] = domain.hash_of(value) if value else ''

        return txn
1327987
def past_trades(self, timestamp=0, symbol='btcusd'):
        
        payload = {
            "request": "/v1/mytrades",
            "nonce": self._nonce,
            "symbol": symbol,
            "timestamp": timestamp
        }

        signed_payload = self._sign_payload(payload)
        r = requests.post(self.URL + "/mytrades", headers=signed_payload, verify=True)
        json_resp = r.json()

        return json_resp
8983
def onBatchCreated(self, three_pc_batch: ThreePcBatch):
        
        ledger_id = three_pc_batch.ledger_id
        if ledger_id == POOL_LEDGER_ID:
            if isinstance(self.poolManager, TxnPoolManager):
                self.get_req_handler(POOL_LEDGER_ID).onBatchCreated(three_pc_batch.state_root, three_pc_batch.pp_time)
        elif self.get_req_handler(ledger_id):
            self.get_req_handler(ledger_id).onBatchCreated(three_pc_batch.state_root, three_pc_batch.pp_time)
        else:
            logger.debug('{} did not know how to handle for ledger {}'.format(self, ledger_id))

        if ledger_id == POOL_LEDGER_ID:
            three_pc_batch.primaries = self.future_primaries_handler.post_batch_applied(three_pc_batch)
        elif not three_pc_batch.primaries:
            three_pc_batch.primaries = self.future_primaries_handler.get_last_primaries() or self.primaries
        self.audit_handler.post_batch_applied(three_pc_batch)

        self.execute_hook(NodeHooks.POST_BATCH_CREATED, ledger_id, three_pc_batch.state_root)
1150229
def find_tx_sender(provider: Provider, raw_tx: dict) -> str:
    ''''''

    vin = raw_tx["vin"][0]
    txid = vin["txid"]
    index = vin["vout"]
    return provider.getrawtransaction(txid, 1)["vout"][index]["scriptPubKey"]["addresses"][0]