def __init__(self, ledger_id: int, config: object, input: RxChannel, output: TxChannel, timer: TimerService, metrics: MetricsCollector, provider: CatchupDataProvider): self._ledger_id = ledger_id self._ledger = provider.ledger(ledger_id) self._config = config self._output = output self._timer = timer self.metrics = metrics self._provider = provider self._state = LedgerState.not_synced # TODO: Improve enum self._catchup_till = None # type: Optional[CatchupTill] self._num_txns_caught_up = 0 services_tx, services_rx = create_direct_channel() router = Router(services_rx) router.add(LedgerCatchupStart, self._on_catchup_start) router.add(LedgerCatchupComplete, self._on_catchup_complete) self._cons_proof_service = ConsProofService(ledger_id=ledger_id, config=config, input=input, output=services_tx, timer=self._timer, metrics=self.metrics, provider=self._provider) self._catchup_rep_service = CatchupRepService(ledger_id=ledger_id, config=config, input=input, output=services_tx, timer=self._timer, metrics=self.metrics, provider=self._provider)
def __init__(self, ledger_id: int, config: object, input: RxChannel, output: TxChannel, timer: TimerService, metrics: MetricsCollector, provider: CatchupDataProvider): router = Router(input) router.add(LedgerStatus, self.process_ledger_status) router.add(ConsistencyProof, self.process_consistency_proof) self._ledger_id = ledger_id self._ledger = provider.ledger(ledger_id) self._config = config self._output = output self._timer = timer self.metrics = metrics self._provider = provider self._is_working = False self._quorum = Quorums(len(self._provider.all_nodes_names())) self._same_ledger_status = set() self._cons_proofs = {} self._already_asked_for_cons_proofs_without_timeout = False self._last_txn_3PC_key = {} self._ledger_status_timer = \ RepeatingTimer(self._timer, self._config.LedgerStatusTimeout * (len(self._provider.all_nodes_names()) - 1), self._reask_for_ledger_status, active=False) self._consistency_proof_timer = \ RepeatingTimer(self._timer, self._config.ConsistencyProofsTimeout * (len(self._provider.all_nodes_names()) - 1), self._reask_for_last_consistency_proof, active=False)
def __init__(self, ledger_id: int, config: object, input: RxChannel, output: TxChannel, timer: TimerService, metrics: MetricsCollector, provider: CatchupDataProvider): Router(input).add(CatchupRep, self.process_catchup_rep) self._ledger_id = ledger_id self._ledger = provider.ledger(ledger_id) self._config = config self._output = output self._timer = timer self.metrics = metrics self._provider = provider self._is_working = False self._catchup_till = None # type: Optional[CatchupTill] # Nodes are added in this set when the current node sent a CatchupReq # for them and waits a CatchupRep message. self._wait_catchup_rep_from = set() self._received_catchup_replies_from = defaultdict(list) # type: Dict[int, List] self._received_catchup_txns = [] # type: List[Tuple[int, Any]]
def build_broken_ledger_status(ledger_id: int, provider: CatchupDataProvider): nonlocal next_size if provider.node_name() != lagging_node.name: return orig_method(ledger_id, provider) if ledger_id != AUDIT_LEDGER_ID: return orig_method(ledger_id, provider) audit_ledger = provider.ledger(AUDIT_LEDGER_ID) size = audit_ledger.size next_size = next_size + 1 if next_size < size else 1 print("new size {}".format(next_size)) newRootHash = Ledger.hashToStr( audit_ledger.tree.merkle_tree_hash(0, next_size)) ledgerStatus = LedgerStatus(AUDIT_LEDGER_ID, next_size, 0, 0, newRootHash, CURRENT_PROTOCOL_VERSION) logger.info("audit status {}".format(ledgerStatus)) return ledgerStatus
def __init__(self, ledger_id: int, config: object, input: RxChannel, output: TxChannel, timer: TimerService, metrics: MetricsCollector, provider: CatchupDataProvider): router = Router(input) router.add(LedgerStatus, self.process_ledger_status) router.add(ConsistencyProof, self.process_consistency_proof) self._ledger_id = ledger_id self._ledger = provider.ledger(ledger_id) self._config = config self._output = output self._timer = timer self.metrics = metrics self._provider = provider self._is_working = False self._quorum = Quorums(len(self._provider.all_nodes_names())) self._same_ledger_status = set() self._cons_proofs = {} self._requested_consistency_proof = set() self._last_txn_3PC_key = {}
def build_broken_ledger_status(ledger_id: int, provider: CatchupDataProvider): nonlocal next_size if provider.node_name() != new_node.name: return origMethod(ledger_id, provider) if ledger_id != DOMAIN_LEDGER_ID: return origMethod(ledger_id, provider) domain_ledger = provider.ledger(DOMAIN_LEDGER_ID) size = domain_ledger.size next_size = next_size + 1 if next_size < size else 1 print("new size {}".format(next_size)) newRootHash = Ledger.hashToStr( domain_ledger.tree.merkle_tree_hash(0, next_size)) three_pc_key = provider.three_phase_key_for_txn_seq_no( ledger_id, next_size) v, p = three_pc_key if three_pc_key else None, None ledgerStatus = LedgerStatus(1, next_size, v, p, newRootHash, CURRENT_PROTOCOL_VERSION) print("dl status {}".format(ledgerStatus)) return ledgerStatus