Home Reference Source
public class | source

ChainStore

You can directly use an instance of this class. chain_store

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public

tracks everyone who wants to receive updates when the cache changes

public

timeout: *

public
public

workers: *

Method Summary

Public Methods
public

addProposalData(approvals: *, objectId: *): *

public

Clears all cached state.

public

Clear an object from the cache to force it to be fetched again.

public
public

fetchCommitteeMemberByAccount(account_id: *): *

public

fetchFullAccount(an: *): *

Fetches an account and all of its associated data in a single query

public

fetchObject(id: *, force: boolean, autosubscribe: boolean, no_full_account: boolean): *

If there is not already a pending request to fetch this object, a new request will be made.

public

fetchRecentHistory(account: *): *

There are two ways to extend the account history, add new more recent history, and extend historic hstory.

public

fetchWitnessByAccount(account_id: *): *

public

getAccount(name_or_id: *, autosubscribe: boolean): *

public

getAccountBalance(account: *, asset_type: *): number

public
public

getAccountName(id: *): *

public
public

getAccountRefsOfKey(the: *): *

public

getAsset(id_or_symbol: *): *

public

getBalanceObjects(address: *): *

public

getCommitteeMemberById(account_id: *): *

This method will attempt to lookup committee member by account_id.

public
public
public

getObject(id: *, force: boolean, autosubscribe: boolean, no_full_account: boolean): *

There are three states an object id could be in:

public

getObjectByVoteID(vote_id: *): *

public

getObjectsByVoteIds(vote_ids: *): *

public

getWitnessById(account_id: *): *

This method will attempt to lookup witness by account_id.

public

init(subscribe_to_new: boolean): *

public
public

onUpdate(updated_objects: *)

public

resetCache(subscribe_to_new: *): *

public
public

subscribe(callback: *): *

Add a callback that will be called anytime any object in the cache is updated

public

unSubFrom(type: *, id: *)

public

unsubscribe(callback: *): *

Remove a callback that was previously added via subscribe

Private Methods
private

_isSubbedTo(type: *, id: *): *

private

_subTo(type: *, id: *)

private

_updateObject(object: *, notify_subscribers: boolean, emit: boolean): *

Updates the object in place by only merging the set properties of object.

Public Constructors

public constructor() source

Public Members

public account_history_requests: * source

public account_ids_by_account: * source

public account_ids_by_key: * source

public accounts_by_name: * source

public assets_by_symbol: * source

public balance_objects_by_address: * source

public chain_time_offset: *[] source

public committee_by_account_id: * source

public dispatchFrequency: number source

public dispatched: boolean source

public fetching_get_full_accounts: * source

public get_account_refs_of_accounts_calls: * source

public get_account_refs_of_keys_calls: * source

public get_full_accounts_subscriptions: * source

public head_block_time_string: * source

public objects_by_id: * source

public objects_by_vote_id: * source

public subError: * source

public subbed_accounts: * source

public subbed_committee: * source

public subbed_witnesses: * source

public subscribed: boolean source

public subscribers: * source

tracks everyone who wants to receive updates when the cache changes

public timeout: * source

public witness_by_account_id: * source

public workers: * source

Public Methods

public addProposalData(approvals: *, objectId: *): * source

Params:

NameTypeAttributeDescription
approvals *
objectId *

Return:

*

public clearCache() source

Clears all cached state. This should be called any time the network connection is reset.

public clearObjectCache(id: *) source

Clear an object from the cache to force it to be fetched again. This may be useful if a query failed the first time and the wallet has reason to believe it may succeede the second time.

Params:

NameTypeAttributeDescription
id *

public fetchAllWorkers(): * source

Return:

*

a promise with the workers array

public fetchCommitteeMemberByAccount(account_id: *): * source

Params:

NameTypeAttributeDescription
account_id *

Return:

*

a promise with the witness object

public fetchFullAccount(an: *): * source

Fetches an account and all of its associated data in a single query

Params:

NameTypeAttributeDescription
an *

account name or account id

Return:

*

null if the object has been queried and was not found

public fetchObject(id: *, force: boolean, autosubscribe: boolean, no_full_account: boolean): * source

If there is not already a pending request to fetch this object, a new request will be made.

Params:

NameTypeAttributeDescription
id *
force boolean
  • optional
  • default: false
autosubscribe boolean
  • optional
  • default: true
no_full_account boolean
  • optional
  • default: false

Return:

*

the object if it does exist and is in our cache

public fetchRecentHistory(account: *): * source

There are two ways to extend the account history, add new more recent history, and extend historic hstory. This method will fetch the most recent account history and prepend it to the list of historic operations.

Params:

NameTypeAttributeDescription
account *

immutable account object

Return:

*

a promise with the account history

public fetchWitnessByAccount(account_id: *): * source

Params:

NameTypeAttributeDescription
account_id *

Return:

*

a promise with the witness object

public getAccount(name_or_id: *, autosubscribe: boolean): * source

Params:

NameTypeAttributeDescription
name_or_id *
autosubscribe boolean
  • optional
  • default: true

Return:

*

the account object if it does exist

public getAccountBalance(account: *, asset_type: *): number source

Params:

NameTypeAttributeDescription
account *
asset_type *

Return:

number

public getAccountMemberStatus(account: *): string source

Params:

NameTypeAttributeDescription
account *

Return:

string

public getAccountName(id: *): * source

Params:

NameTypeAttributeDescription
id *

Return:

*

the account name

public getAccountRefsOfAccount(the: *): * source

Params:

NameTypeAttributeDescription
the *

account id to find accounts that reference it

Return:

*

undefined if the result is unknown

If this method returns undefined, then it will send a request to the server for the current set of accounts after which the server will notify us of any accounts that reference these keys

public getAccountRefsOfKey(the: *): * source

Params:

NameTypeAttributeDescription
the *

public key to find accounts that reference it

Return:

*

undefined if the result is unknown

If this method returns undefined, then it will send a request to the server for the current set of accounts after which the server will notify us of any accounts that reference these keys

public getAsset(id_or_symbol: *): * source

Params:

NameTypeAttributeDescription
id_or_symbol *

Return:

*

object if the id_or_symbol exists

public getBalanceObjects(address: *): * source

Params:

NameTypeAttributeDescription
address *

Return:

*

a empty Set if no items are found

If this method returns undefined, then it will send a request to the server for the current state after which it will be subscribed to changes to this set.

public getCommitteeMemberById(account_id: *): * source

This method will attempt to lookup committee member by account_id. If committee member doesn't exist it will return null, if committee member is found it will return committee member object, if it's not fetched yet it will return undefined.

Params:

NameTypeAttributeDescription
account_id *

account id

Return:

*

public getEstimatedChainTimeOffset(): * source

Return:

*

public getHeadBlockDate(): * source

Return:

*

public getObject(id: *, force: boolean, autosubscribe: boolean, no_full_account: boolean): * source

There are three states an object id could be in:

  1. undefined - returned if a query is pending
  2. defined - return an object
  3. null - query return null

Params:

NameTypeAttributeDescription
id *
force boolean
  • optional
  • default: false
autosubscribe boolean
  • optional
  • default: true
no_full_account boolean
  • optional
  • default: false

Return:

*

public getObjectByVoteID(vote_id: *): * source

Params:

NameTypeAttributeDescription
vote_id *

Return:

*

public getObjectsByVoteIds(vote_ids: *): * source

Params:

NameTypeAttributeDescription
vote_ids *

Return:

*

public getWitnessById(account_id: *): * source

This method will attempt to lookup witness by account_id. If witness doesn't exist it will return null, if witness is found it will return witness object, if it's not fetched yet it will return undefined.

Params:

NameTypeAttributeDescription
account_id *

account id

Return:

*

public init(subscribe_to_new: boolean): * source

Params:

NameTypeAttributeDescription
subscribe_to_new boolean
  • optional
  • default: true

Return:

*

public notifySubscribers() source

public onUpdate(updated_objects: *) source

Params:

NameTypeAttributeDescription
updated_objects *

public resetCache(subscribe_to_new: *): * source

Params:

NameTypeAttributeDescription
subscribe_to_new *

Return:

*

public setDispatchFrequency(freq: *) source

Params:

NameTypeAttributeDescription
freq *

public subscribe(callback: *): * source

Add a callback that will be called anytime any object in the cache is updated

Params:

NameTypeAttributeDescription
callback *

Return:

*

public unSubFrom(type: *, id: *) source

Params:

NameTypeAttributeDescription
type *
id *

public unsubscribe(callback: *): * source

Remove a callback that was previously added via subscribe

Params:

NameTypeAttributeDescription
callback *

Return:

*

Private Methods

private _isSubbedTo(type: *, id: *): * source

Params:

NameTypeAttributeDescription
type *
id *

Return:

*

private _subTo(type: *, id: *) source

Params:

NameTypeAttributeDescription
type *
id *

private _updateObject(object: *, notify_subscribers: boolean, emit: boolean): * source

Updates the object in place by only merging the set properties of object.

This method will create an immutable object with the given ID if it does not already exist.

This is a "private" method called when data is received from the server and should not be used by others.

Params:

NameTypeAttributeDescription
object *
notify_subscribers boolean
  • optional
  • default: false
emit boolean
  • optional
  • default: true

Return:

*

an Immutable constructed from object and deep merged with the current state