Exemple #1
0
 def send(self, cluster_url: str, message: Message) -> None:
     for party, message_types in KEY_MAP.items():
         if isinstance(message, message_types):
             priv_key, _ = self.select_keys(party)
             break
     else:
         raise Exception(f'Unsupported Message Type: {type(message)}')
     print_message(message, cluster_url, 'send')
     sign_message(get_field_from_message(message, 'task_to_compute'), self.requestor_private_key)
     serialized_message = dump(message, priv_key, self.concent_pub_key)
     self._exchange_message(priv_key, cluster_url, serialized_message)
Exemple #2
0
def _get_field_value_and_encode_if_bytes_from_message(
        field_name: str, golem_message: Message) -> str:
    value = get_field_from_message(golem_message, field_name)
    if isinstance(value, bytes):
        value = encode_hex(value)
    return str(value)
Exemple #3
0
def _get_field_value_from_messages_for_logging(
        field_name: MessageIdField,
        message: Message) -> Union[str, Dict[str, str]]:
    value = get_field_from_message(message, field_name.value) if isinstance(
        message, Message) else '-not available- '
    return value if value is not None else '-not available- '
Exemple #4
0
def _get_field_value_from_messages_for_logging(field_name: MessageIdField,
                                               message: Message) -> str:
    value: str = get_field_from_message(
        message, field_name.value) if isinstance(
            message, Message) else '-not available-'  # type: ignore
    return value if value is not None else '-not available-'