Пример #1
0
 def load_state(self) -> MonitoringServiceState:
     """ Load MS state from db or return a new empty state if not saved one is present
     """
     blockchain = self.conn.execute("SELECT * FROM blockchain").fetchone()
     ms_state = MonitoringServiceState(
         blockchain_state=self.get_blockchain_state(), address=blockchain["receiver"]
     )
     return ms_state
Пример #2
0
    def load_state(self) -> MonitoringServiceState:
        """ Load MS state from db or return a new empty state if not saved one is present
        """
        blockchain = self.conn.execute("SELECT * FROM blockchain").fetchone()
        token_network_addresses = [
            row[0] for row in self.conn.execute("SELECT address FROM token_network")
        ]
        latest_known_block = blockchain['latest_known_block']

        chain_state = BlockchainState(
            chain_id=blockchain['chain_id'],
            token_network_registry_address=blockchain['token_network_registry_address'],
            monitor_contract_address=blockchain['monitor_contract_address'],
            latest_known_block=latest_known_block,
            token_network_addresses=token_network_addresses,
        )
        ms_state = MonitoringServiceState(
            blockchain_state=chain_state, address=blockchain['receiver']
        )
        return ms_state