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.


Constructors

init:(NSString *) db_path :(long) settingsPtr :(NSError **) error

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

Parameters

Parameter Description

NSString * dbPath

File path of the Keychain database

long settingsPtr

This is the settings pointer from an instantiated Gateway class


Method Summary

Return type Method and Description

BOOL

onPause :(NSError **) error

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

BOOL

onResume :(NSError **) error

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.

BOOL

onStart :(NSError **) error

Create the Monitor thread if it does not already exist.

BOOL

onStop :(NSError **) error

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.