diff --git a/src/blockperf/config.py b/src/blockperf/config.py index e6e717f..cebbed6 100644 --- a/src/blockperf/config.py +++ b/src/blockperf/config.py @@ -3,6 +3,8 @@ configparser module. """ +import base64 +import hashlib import ipaddress import json import logging @@ -43,6 +45,7 @@ def __init__(self, config_file: Union[Path, None] = None, verbose=False): f"Node config: {self.node_config_file}\n" f"Node logfile: {self.node_logfile}\n" f"Client Name: {self.name}\n" + f"Client ID: {self.clientid}\n" f"Networkmagic: {self.network_magic}\n" f"Public IP: {self.relay_public_ip}:{self.relay_public_port}\n" # f"..... {blocksample.block_delay} sec\n\n" @@ -107,6 +110,14 @@ def check_blockperf_config(self): "MaximalVerbosity", ), "TracingVerbosity must be NormalVerbosity or MaximalVerbosity" + @property + def clientid(self) -> str: + certid = "" + with open(self.client_cert, mode="r") as f: + cert_string = "".join(f.readlines()[1:-1]) + certid = hashlib.sha256(base64.b64decode(cert_string)).hexdigest() + return certid + @property def broker_host(self) -> str: broker_host = os.getenv(