Class Monitor

  • NSObject

    • KeychainCore/Monitor

Monitor

Monitor subscribes to block updates from the blockchain and updates the database cache state of Persona and Contacts accordingly. Monitor updates attributes such as number of confirmations, public keys and metadata, certificate transaction data. A thread for Monitoring the blockchain state is created in the onStart method.

Monitor method names should be read as "what the Monitor should do in response to the underlying execution environment entering the specified state". For instance, you should call onStart once your application has set the active persona and is ready to receive updates.

Please note that the Monitor thread is not started during onStart; it is merely created during that method. This is because some execution environments (namely mobile device environments) prefer to decouple the creation and start states of applications and intend the start process to be as lightweight as possible.


Constructor

Constructor and Description

public init(_ dbPath: String!, _ settingsPtr: Int) throws

dbPath File path of the Keychain database

settingsPtr This is the settings pointer from an instantiated Gateway class

You should instantiate Gateway before instantiating the Monitor. And pass gateway.settingsPtr as the settingsPtr argument to the constructor of the Monitor class.


Method Summary

Return type Method and Description

void

open func onPause() throws

Pause (block) the Monitor thread if it was unblocked and running. The thread will remain paused until onResume() is called.

void

open func onResume() throws

This method starts/unblocks the Monitor thread if it was blocked or not running. If the thread does not exist upon calling onResume, onResume will call onStart to create the thread. The thread will remain running until onPause is called.

void

open func onStart() throws

Create the Monitor thread if it does not already exist.

void

open func onStop() throws

Stop and destroy the Monitor thread if it exists. If the thread is running, this method will (safely) cause the thread to stop execution before destroying the thread.

Thread Safety

This class is fully thread-safe; any of its methods may be invoked in multiple threads concurrently.

Idempotence

This class’s methods are idempotent.