Esempio n. 1
0
    def _register(self):
        LOG.debug(f"Register handlers")
        self._stream.wait_for_ready()
        future = self._stream.send(
            message_type=Message.CLIENT_EVENTS_SUBSCRIBE_REQUEST,
            content=ClientEventsSubscribeRequest(
                last_known_block_ids=[NULL_BLOCK_ID],
                subscriptions=[
                    EventSubscription(event_type="sawtooth/block-commit"),
                    EventSubscription(
                        event_type="sawtooth/state-delta",
                        filters=[
                            EventFilter(
                                key="address",
                                match_string=f"^{Namespaces.GA_NAMESPACE}.*",
                                filter_type=EventFilter.REGEX_ANY,
                            )
                        ],
                    ),
                ],
            ).SerializeToString(),
        )

        resp = TpRegisterResponse()
        try:
            resp.ParseFromString(future.result().content)
            LOG.info("Register response: %s",
                     TpRegisterResponse.Status.Name(resp.status))
        except ValidatorConnectionError as vce:
            LOG.info("During waiting for response on registration: %s", vce)
        except Exception as e:
            LOG.info("During waiting for response on registration: %s", e)
    def _register(self):
        futures = []
        for message in self._register_requests():
            self._stream.wait_for_ready()
            future = self._stream.send(
                message_type=Message.TP_REGISTER_REQUEST,
                content=message.SerializeToString())
            futures.append(future)

        for future in futures:
            resp = TpRegisterResponse()
            try:
                resp.ParseFromString(future.result().content)
                if resp.protocol_version != \
                        self._highest_sdk_feature_requested.value:
                    LOGGER.error(
                        "Validator version %s does not support "
                        "requested feature by SDK version %s. "
                        "Unregistering with the validator.",
                        str(resp.protocol_version),
                        str(self._highest_sdk_feature_requested.value))
                    raise ValidatorVersionError()
                LOGGER.info("register attempt: %s",
                            TpRegisterResponse.Status.Name(resp.status))
                if resp.status == TpRegisterResponse.ERROR:
                    raise RuntimeError("Transaction processor registration "
                                       "failed")
            except ValidatorConnectionError as vce:
                LOGGER.info("during waiting for response on registration: %s",
                            vce)
Esempio n. 3
0
    def register_processor(self):
        message, ident = self.receive()
        if message.message_type != Message.TP_REGISTER_REQUEST:
            return False

        self._tp_ident = ident

        request = TpRegisterRequest()
        request.ParseFromString(message.content)
        LOGGER.debug("Processor registered: %s, %s, %s", str(request.family),
                     str(request.version), str(request.namespaces))
        response = TpRegisterResponse(status=TpRegisterResponse.OK)
        self.send(response, message.correlation_id)
        return True
Esempio n. 4
0
    def register_processor(self):
        message, ident = self.receive()
        if message.message_type != Message.TP_REGISTER_REQUEST:
            return False
        else:
            self._tp_ident = ident

            request = TpRegisterRequest()
            request.ParseFromString(message.content)
            print("Processor registered: {}, {}, {}, {}".format(
                request.family, request.version,
                request.encoding, request.namespaces
            ))
            response = TpRegisterResponse(
                status=TpRegisterResponse.OK)
            self.send(response, message.correlation_id)
            return True
Esempio n. 5
0
    def _register(self):
        futures = []
        for message in self._register_requests():
            self._stream.wait_for_ready()
            future = self._stream.send(
                message_type=Message.TP_REGISTER_REQUEST,
                content=message.SerializeToString())
            futures.append(future)

        for future in futures:
            resp = TpRegisterResponse()
            try:
                resp.ParseFromString(future.result().content)
                LOGGER.info("register attempt: %s",
                            TpRegisterResponse.Status.Name(resp.status))
            except ValidatorConnectionError as vce:
                LOGGER.info("during waiting for response on registration: %s",
                            vce)