Methods
add()
Adds an event to associate with a ledger given an event and a set of options.
event - the event to associate with a ledger. meta - the metadata that is associated with the event. eventHash - the hash of the event data. callback(err, result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the result of the operation. event - the event that was committed to storage. meta - the metadata that was committed to storage.
add(block, emit, meta, callback(err))
Adds a block in the ledger given a block, metadata associated with the block.
Parameters:
Name | Type | Description |
---|---|---|
block |
the block to create in the ledger. blockHeight - the height of the block. event - an array of events associated with the block. |
|
emit |
when true (default), a bedrock event is emitted to inform listeners that a block has been added. |
|
meta |
the metadata associated with the block. blockHash - the hash value of the block. |
|
callback(err) |
the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the result of the operation. block - the block that was committed to storage. meta - the metadata that was committed to storage. |
add()
Adds an operation to mutate the state of a ledger.
operation - the operation to perform. options - a set of options used when adding the operation. callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise.
change()
Submits a new ledgerConfiguration for the ledger. The change will not occur until the current consensus mechanism accepts the ledgerConfiguration and the state machine processes it.
ledgerConfiguration - the new ledgerConfiguration for the ledger. [genesis] - boolean - is this genesis config [genesisBlock] - a genesis block for a ledger callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise.
difference(eventHash, callback(err,)
Identify events that are not in storage.
Parameters:
Name | Type | Description |
---|---|---|
eventHash |
the hash or array of hashes to check. |
|
callback(err, |
result) called onced the operation completes. |
exists(eventHash, operationHash, callback(err,)
Determine if operations exist.
Parameters:
Name | Type | Description |
---|---|---|
eventHash |
the hash of the event associated with the operation |
|
operationHash |
the hash or array of hashes of the operation(s). |
|
callback(err, |
result) called once the operation completes. |
exists(eventHash, callback(err,)
Determine if an event with a given hash exists.
Parameters:
Name | Type | Description |
---|---|---|
eventHash |
the hash or array of hashes of the event(s). |
|
callback(err, |
result) called once the operation completes. |
get()
Gets the current ledgerConfiguration for the ledger.
callback(err) - the callback to call when finished.
err - An Error if an error occurred, null otherwise.
ledgerConfiguration - the latest ledgerConfiguration or null
if none.
get(blockId, consensusopt, callback(err,)
Gets the block that has consensus given a blockId.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
blockId |
the identifier of the block that has consensus. |
||
consensus |
<optional> |
|
|
callback(err, |
block) - the callback to call when finished. err - An Error if an error occurred, null otherwise. block - the block with the given ID that has consensus. |
get()
Gets a record from the ledger given a recordID and a set of options.
[maxBlockHeight] - limit the record history to the specified block height. recordId - the URI of the object to fetch. callback(err, {meta, record}) - the callback to call when finished. err - An Error if an error occurred, null otherwise.
get()
Gets an event in the ledger given a query and a set of options.
eventHash - the hash of the event to fetch from storage. callback(err, result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the result of the retrieval event - the event. meta - metadata about the event.
get()
Gets metadata associated with the ledger, such as most recent configuration block and latest consensus block, given a set of options.
actor - the actor performing the action. options - a set of options used when retrieving the ledger metadata. callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise. ledgerMeta - metadata about the ledger.
get()
Gets an event associated with the ledger given an eventID and a set of options.
eventId - the event to fetch from the ledger. options - a set of options used when retrieving the event. callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise. event - the event that was retrieved from the database.
get(blockId, consensusopt, callback(err))
Gets a block from the ledger given a blockID and a set of options.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
blockId |
the URI of the block to fetch. |
||
consensus |
<optional> |
|
|
callback(err) |
the callback to call when finished. err - An Error if an error occurred, null otherwise. |
getActiveConfig()
Gets the active configuration based on blockHeight. A ledger configuration is active for blocks that are subsequent to the block that includes the ledger configuration event itself.
blockHeight - the blockHeight used to locate the ledger configuration. callback(err, result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the result of the retrieval. event - the event. meta - metadata about the event.
getAll(blockId, callback(err,)
Gets all blocks matching a given blockId even if they have not achieved consensus.
Parameters:
Name | Type | Description |
---|---|---|
blockId |
the identifier of the block(s) to fetch from the ledger. |
|
callback(err, |
iterator) - the callback to call when finished. err - An Error if an error occurred, null otherwise. iterator - an iterator for all of the returned blocks. |
getByHeight(blockHeight, callback(err,)
Gets a block that has consensus given a blockHeight.
Parameters:
Name | Type | Description |
---|---|---|
blockHeight |
the height of the block that has consensus. |
|
callback(err, |
block) - the callback to call when finished. err - An Error if an error occurred, null otherwise. block - the block with the given block height that has consensus. |
getCount(consensus, type, callback(err,)
Gets a count of events.
Parameters:
Name | Type | Description |
---|---|---|
consensus |
filter events based on consensus status. |
|
type |
filter events based on event type. |
|
callback(err, |
count) - the callback to call when finished. |
getGenesis(callback(err,)
Retrieves the genesis block from the ledger.
Parameters:
Name | Type | Description |
---|---|---|
callback(err, |
result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the result with the genesis block. genesisBlock - the genesis block and its meta. |
getGenesis()
Gets the genesis block from the ledger.
callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise.
getLatest(callback(err))
Gets the latest blocks from the ledger.
Parameters:
Name | Type | Description |
---|---|---|
callback(err) |
the callback to call when finished. err - An Error if an error occurred, null otherwise. |
getLatest(callback(err,)
Retrieves the latest block from the ledger.
Parameters:
Name | Type | Description |
---|---|---|
callback(err, |
result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the block. eventBlock - the latest events block and meta. |
getLatestConfig()
Gets the latest configuration event that has consensus.
callback(err, result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the result of the retrieval. event - the event. meta - metadata about the event.
getLatestSummary(callback(err,)
Retrieves a summary of the latest block from the ledger.
Parameters:
Name | Type | Description |
---|---|---|
callback(err, |
result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the block. eventBlock - the latest events block summary. |
getSummary(blockId, consensusopt, eventHashopt, callback(err,)
Gets the block summary for consensus block given a blockId.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
blockId |
the identifier of the block that has consensus. |
||
consensus |
<optional> |
|
|
eventHash |
<optional> |
|
|
callback(err, |
block) - the callback to call when finished. err - An Error if an error occurred, null otherwise. block - the block summary for the given ID that has consensus. |
getSummaryByHeight(blockHeight, consensusopt, eventHashopt, callback(err,)
Gets the block summary for consensus block given a blockHeight.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
blockHeight |
the height of the block that has consensus. |
||
consensus |
<optional> |
|
|
eventHash |
<optional> |
|
|
callback(err, |
block) - the callback to call when finished. err - An Error if an error occurred, null otherwise. block - the block summary for the given ID that has consensus. |
remove()
Delete an event associated with the ledger given an event hash and a set of options.
eventHash - the hash of the event to delete. options - a set of options used when deleting the event. callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise.
remove(blockHash, callback(err))
Delete a block in the ledger given a block hash and a set of options.
Parameters:
Name | Type | Description |
---|---|---|
blockHash |
the hash of the block to delete. |
|
callback(err) |
the callback to call when finished. err - An Error if an error occurred, null otherwise. |
update()
Update an existing event associated with the ledger given an eventId, an array of patch instructions, and a set of options.
eventHash - the ID of the event to update patch - a list of patch commands for the event callback(err, result) - the callback to call when finished. err - An Error if an error occurred, null otherwise. result - the value of the updated event.
update(blockHash, patch, callback(err))
Update an existing block in the ledger given a block hash, an array of patch instructions, and a set of options.
Parameters:
Name | Type | Description |
---|---|---|
blockHash |
the hash of the block to update. |
|
patch |
the patch instructions to execute on the block. |
|
callback(err) |
the callback to call when finished. err - An Error if an error occurred, null otherwise. |
validate()
Validates an operation against the current configuration.
operation - the operation to validate. callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise.
validate()
Validates a ledgerConfiguration.
ledgerConfiguration - the ledgerConfiguration to validate. callback(err) - the callback to call when finished. err - An Error if an error occurred, null otherwise.