Module: lib/protocol/state

Module for Whiteflag protocol state management

Source:
Tutorials:
To Do:
  • Review blockchain account backup method

Methods

(inner) backupAccount(blockchain, address)

Saves a specific blockchain account to file

Parameters:
Name Type Description
blockchain string

the blockchain of the account to be saved

address string

the address of the account to be saved

Source:

(inner) checkState(stateData) → {Object}

Checks state and performs updates from old versions

Parameters:
Name Type Description
stateData Object
Source:
Returns:

updated state

Type
Object

(inner) closeState(callbackopt)

Ensures a proper shutdown

Parameters:
Name Type Attributes Description
callback errorCb <optional>

function called after initialising/restoring state

Source:
Fires:
  • module:lib/protocol/events.stateEvent:closed

(inner) getBlockchainData(blockchain, callback)

Gets state of a specific blockchain

Parameters:
Name Type Description
blockchain string

name of the blockchain

callback genericCb

function to which data is passed

Source:

(inner) getBlockchains(callbackopt) → {blockchainsData}

Returns blockchain state data to callback

Parameters:
Name Type Attributes Description
callback genericCb <optional>

function to which data is passed

Source:
Returns:
Type
blockchainsData

(inner) getKey(category, id, callback)

Gets a cryptographic key

Parameters:
Name Type Description
category string

the key category

id string

unique identifier of the key

callback genericCb

function to which the key is passed

Source:

(inner) getKeyIds(category, callback)

Returns all key ids of a cryptographic key category

Parameters:
Name Type Description
category string

the key category

callback genericCb

function to which the key is passed

Source:

(inner) getOriginatorAuthToken(authTokenId, callback)

Returns originator authentication token

Parameters:
Name Type Description
authTokenId string

the originator's authentication token

callback genericCb

function to which data is passed

Source:

(inner) getOriginatorData(address, callback)

Gets state of a specific originator

Parameters:
Name Type Description
address string

the originator's blockchain address

callback genericCb

function to which data is passed

Source:

(inner) getOriginators(callback)

Returns originator state data to callback

Parameters:
Name Type Description
callback genericCb

function to which data is passed

Source:

(inner) getQueue(queue, callback)

Returns specific queue to callback

Parameters:
Name Type Description
queue string

the name of the queue

callback genericCb

function to which data is passed

Source:

(inner) getQueueData(queue, property, value, callback)

Gets specific item from specific queue

Parameters:
Name Type Description
queue string

the name of the queue

property string

the data object property name by which the item is identified

value Object

the value of the property by which the item is identified

callback genericCb

function to which data is passed

Source:

(inner) initState(callback)

Restores previous state from file and binds event handlers to state changes

Parameters:
Name Type Description
callback errorCb

function called after initialising/restoring state

Source:
Fires:
  • module:lib/protocol/events.stateEvent:initialised

(inner) removeKey(category, id)

Removes a cryptographic key

Parameters:
Name Type Description
category string

the key category

id string

unique identifier of the key

Source:
Fires:
  • module:lib/protocol/events.stateEvent:removedKey

(inner) removeOriginatorAuthToken(address)

Removes originator authentication data

Parameters:
Name Type Description
address string

the originator's blockchain address

Source:
Fires:
  • module:lib/protocol/events.stateEvent:removedAuthenticationToken
  • module:lib/protocol/events.stateEvent:removedOriginatorAuthToken

(inner) removeOriginatorData(address)

Removes state of a specific originator

Parameters:
Name Type Description
address string

the originator's blockchain address

Source:
Fires:
  • module:lib/protocol/events.stateEvent:removedOriginator

(inner) removeQueueData(queue, property, value)

Removes specific item in specific queue

Parameters:
Name Type Description
queue string

the name of the queue

property string

the data object property name by which the item is identified

value Object

the value of the property by which the item to be removed is identified

Source:
Fires:
  • module:lib/protocol/events.stateEvent:removedFromQueue

(inner) saveState()

Saves current state to file

Source:
Fires:
  • module:lib/protocol/events.stateEvent:saved

(inner) updateBlockchains(blockchain, data)

Updates state of a specific blockchain

Parameters:
Name Type Description
blockchain string

name of the blockchain

data Object

parameters of the specific blockchain

Source:
Fires:
  • module:lib/protocol/events.stateEvent:updatedBlockchain

(inner) upsertKey(category, id, key)

Inserts or updates a cryptographic key

Parameters:
Name Type Description
category string

the key category

id string

unique identifier of the key

key string

the key to be stored or updated in raw hexadecimal format

Source:
Fires:
  • module:lib/protocol/events.stateEvent:insertedKey
  • module:lib/protocol/events.stateEvent:updatedKey

(inner) upsertOriginatorData(data)

Inserts or updates an originator

Parameters:
Name Type Description
data Object

originator data

Source:
Fires:
  • module:lib/protocol/events.stateEvent:insertedOriginator
  • module:lib/protocol/events.stateEvent:updatedOriginator
  • module:lib/protocol/events.stateEvent:insertedAuthenticationToken
  • module:lib/protocol/events.stateEvent:updatedAuthenticationToken

(inner) upsertQueueData(queue, property, data)

Inserts or updates specific item in specific queue

Parameters:
Name Type Description
queue string

the name of the queue

property string

the data object property name by which the item is identified

data Object

the data to be updated or put on queue

Source:
Fires:
  • module:lib/protocol/events.stateEvent:insertedInQueue
  • module:lib/protocol/events.stateEvent:updatedQueue

Type Definitions

blockchainData

Blockchain parameters, status and account data

Type:
  • Object
Properties:
Name Type Description
parameters Object

Blockchain specific parameters, such as name and node information

status Object

Blockchain status, such as current block height, block times, etc.

accounts Array.<wfAccount>

Accounts available on this blockchain

Source:

blockchainsData

State data of all blockchains

Type:
  • Array.<blockchainData>
Source:

originatorData

State data of a specific originator

Type:
  • Object
Properties:
Name Type Description
name string

The name of the originator

blockchain string

The name of the blockchain used by the originator

address string

The blockchain address that identifies the originator

publicKey string

The public key associated with the blockchain account of the originator

ecdhPublicKey string

The state crypto identifier of the ECDH public key of this originator

url string

The url of the authentication signature of the originator

authTokenId string

The state crypto identifier of the authentication token for this originator

authValid boolean

Indication whether the originator has been authenticated at some point in time

authMessages Array.<string>

Transaction hashes of valid original authentication messages

Source:

originatorsData

State data of all originators

Type:
  • Array.<originatorData>
Source:

queueData

State data from a specific queue

Type:
  • Array
Source:

wfState

The Whiteflag state object

Type:
  • Object
Properties:
Name Type Description
blockchains blockchainsData
originators originatorsData
queue Object
crypto Object
Source: