Class Monitor

  • java.lang.Object

    • io.keychain.core.Monitor

public class Monitor

Monitor

Monitor subscribes to updates from the blockchain and updates the database cache state of Personas 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 create in the onStart() method.

Without at least one Monitor the Gateway will run out of sync with the blockchain and will cause the Gateway to be able to perform cryptographic operations properly on subsequent data. Thus, you should ensure that a Monitor is instantiated within the current Activity.

Monitor is implements the Lifecycle Observer pattern and should be registered in the Activity to listen to changes in the Activity state.

The Monitor constructor takes a Refreshable as a parameter. Periodically and/or when a new block has been broadcasted, Monitor will add the Refreshable.onRefresh() on the main Android UI Looper’s queue as a runnable task. This will cause Refreshable.onRefresh() to be run on the main UI thread and refresh the user’s view. This is particularly useful in activities that display the state of Personas and/or Contacts, as it enables the state to refresh automatically.

Constructor Summary

Constructor and Description

Monitor(Context keychainContext, Refreshable refresher)

Instance Methods

Return type Method and Description

void

onPause()

Pause the Monitor thread

void

onResume()

Resume/run the blockchain monitor thread

void

onStart()

Create the blockchain monitor thread

void

onStop()

Stop and destroy the blockchain monitor thread