diff --git a/connectivity/constants.py b/connectivity/constants.py index de520f6..9662e1e 100644 --- a/connectivity/constants.py +++ b/connectivity/constants.py @@ -2,4 +2,6 @@ MOBILE_GPS = 3 PING_MODEL = 1 STATION_VERSION = "v0.8.0" -PASKAL2MMHG = 133.32 \ No newline at end of file +PASKAL2MMHG = 133.32 +POLKA_REMOTE_WS = "wss://polkadot.rpc.robonomics.network/" +KSM_REMOTE_WS = "wss://kusama.rpc.robonomics.network" \ No newline at end of file diff --git a/connectivity/src/feeders/datalog_feeder.py b/connectivity/src/feeders/datalog_feeder.py index 80ae425..a3b08b1 100644 --- a/connectivity/src/feeders/datalog_feeder.py +++ b/connectivity/src/feeders/datalog_feeder.py @@ -21,7 +21,7 @@ sort_payload, create_tmp_file, ) -from connectivity.constants import PING_MODEL +from connectivity.constants import PING_MODEL, POLKA_REMOTE_WS, KSM_REMOTE_WS from .ifeeder import IFeeder from .pinning_services import PinningManager @@ -125,25 +125,36 @@ def to_datalog(self, ipfs_hash: str) -> None: :param ipfs_hash: Ipfs hash of the file. """ - account = Account(seed=self.config["datalog"]["suri"]) - rws = RWS(account) + ksm_account = Account(seed=self.config["datalog"]["suri"], remote_ws=KSM_REMOTE_WS) + polkadot_account = Account(seed=self.config["datalog"]["suri"], remote_ws=POLKA_REMOTE_WS) + rws = RWS(ksm_account) try: if rws.get_days_left(): - rws_sub_owner = account.get_address() + rws_sub_owner = ksm_account.get_address() if not rws.is_in_sub(sub_owner_addr=rws_sub_owner, addr=rws_sub_owner): rws.set_devices([rws_sub_owner]) - rws_datalog = Datalog(account, rws_sub_owner=rws_sub_owner) + rws_datalog = Datalog(ksm_account, rws_sub_owner=rws_sub_owner) robonomics_receipt = rws_datalog.record(ipfs_hash) else: - datalog = Datalog(account) + datalog = Datalog(ksm_account) robonomics_receipt = datalog.record(ipfs_hash) logger.info( - f"Datalog Feeder: Ipfs hash sent to Robonomics Parachain and included in block {robonomics_receipt}" + f"Datalog Feeder: Ipfs hash sent to Robonomics KSM Parachain and included in block {robonomics_receipt}" ) DATALOG_STATUS_METRIC.state("success") self.datalog_db.update_status("sent", ipfs_hash) except Exception as e: logger.warning( - f"Datalog Feeder: Something went wrong during extrinsic submission to Robonomics: {e}" + f"Datalog Feeder: Something went wrong during extrinsic submission to KSM Robonomics: {e}" ) DATALOG_STATUS_METRIC.state("error") + try: + datalog = Datalog(polkadot_account) + robonomics_receipt = datalog.record(ipfs_hash) + logger.info( + f"Datalog Feeder: Ipfs hash sent to Robonomics Polkadot Parachain and included in block {robonomics_receipt}" + ) + except Exception as e: + logger.warning( + f"Datalog Feeder: Something went wrong during extrinsic submission to Polkadot Robonomics: {e}" + )