コード例 #1
0
    def process_view_change_message(self, msg: ViewChange, frm: str):
        result = self._validate(msg, frm)
        if result != PROCESS:
            return result, None

        self._logger.info("{} processing {} from {}".format(self, msg, frm))

        self.view_change_votes.add_view_change(msg, frm)

        vca = ViewChangeAck(viewNo=msg.viewNo,
                            name=getNodeName(frm),
                            digest=view_change_digest(msg))
        self.view_change_votes.add_view_change_ack(
            vca, getNodeName(self._data.name))

        if self._data.is_primary:
            self._send_new_view_if_needed()
            return PROCESS, None

        primary_node_name = getNodeName(self._data.primary_name)
        self._logger.info("{} sending {}".format(self, vca))
        self._network.send(vca, [primary_node_name])

        self._finish_view_change_if_needed()
        return PROCESS, None
コード例 #2
0
    def process_view_change_message(self, msg: ViewChange, frm: str):
        result = self._validate(msg, frm)
        if result == STASH_WAITING_VIEW_CHANGE:
            self._stashed_vc_msgs.setdefault(msg.viewNo, 0)
            self._stashed_vc_msgs[msg.viewNo] += 1
            if self._data.quorums.view_change.is_reached(self._stashed_vc_msgs[msg.viewNo]) and \
                    not self._data.waiting_for_new_view:
                self._bus.send(StartViewChange(msg.viewNo))
        if result != PROCESS:
            return result, None

        self._logger.info("{} processing {} from {}".format(self, msg, frm))

        self.view_change_votes.add_view_change(msg, frm)

        vca = ViewChangeAck(viewNo=msg.viewNo,
                            name=getNodeName(frm),
                            digest=view_change_digest(msg))
        self.view_change_votes.add_view_change_ack(
            vca, getNodeName(self._data.name))

        if self._data.is_primary:
            self._send_new_view_if_needed()
            return PROCESS, None

        primary_node_name = getNodeName(self._data.primary_name)
        self._logger.info("{} sending {}".format(self, vca))
        self._network.send(vca, [primary_node_name])

        self._finish_view_change_if_needed()
        return PROCESS, None
コード例 #3
0
    def process_view_change_message(self, msg: ViewChange, frm: str):
        # TODO: Validation

        vca = ViewChangeAck(viewNo=msg.viewNo,
                            name=frm,
                            digest='digest_of_view_change_message')
        self._network.send(vca, self._data.primary_name)
コード例 #4
0
 def _view_change_acks(vc, vc_frm, primary, count):
     digest = view_change_digest(vc)
     non_senders = [
         name for name in validators if name not in [vc_frm, primary]
     ]
     ack_frms = random.sample(non_senders, count)
     return [(ViewChangeAck(viewNo=vc.viewNo, name=vc_frm,
                            digest=digest), ack_frm)
             for ack_frm in ack_frms]
コード例 #5
0
    def process_view_change_message(self, msg: ViewChange, frm: str):
        # TODO: Validation

        # TODO: Probably we should stash messages from future view instead?
        if not self._is_primary(msg.viewNo):
            vca = ViewChangeAck(viewNo=msg.viewNo,
                                name=frm,
                                digest=self._view_change_digest(msg))
            self._network.send(vca, self._data.primary_name)
コード例 #6
0
    def process_view_change_message(self, msg: ViewChange, frm: str):
        result = self._validate(msg, frm)
        if result != PROCESS:
            return result

        self._votes.add_view_change(msg, frm)

        if self._data.is_primary:
            self._send_new_view_if_needed()
            return

        vca = ViewChangeAck(viewNo=msg.viewNo,
                            name=frm,
                            digest=view_change_digest(msg))
        self._network.send(vca, self._data.primary_name)

        self._finish_view_change_if_needed()
コード例 #7
0
ファイル: helper.py プロジェクト: marchon/indy-plenum
def create_view_change_acks(vc, vc_frm, senders):
    digest = view_change_digest(vc)
    senders = [name for name in senders if name != vc_frm]
    return [(ViewChangeAck(viewNo=vc.viewNo, name=vc_frm,
                           digest=digest), ack_frm) for ack_frm in senders]