Module: lib/protocol/state

Module for Whiteflag protocol state management

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

Members

(inner) _wfState :Object

Whiteflag state

Type:
  • Object
Source:

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 function <optional>

function called after initialising/restoring state

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

(inner) getKeyIds(category, callback)

Returns all key ids of a cryptographic key category

Parameters:
Name Type Description
category string

the key category

callback function

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 function

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 function

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 function

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

Gets state of a specific blockchain

Type:
  • Object
Source:

blockchainsData

Returns blockchain state data to callback

Type:
  • Object
Source:

key

Gets a cryptographic key

Type:
  • string
Source:

originatorData

Gets state of a specific originator

Type:
  • Object
Source:

originatorsData

Returns originator state data to callback

Type:
  • Array
Source:

queueData

Returns specific queue to callback

Type:
  • Array
Source: