Skip to main content

READ DIGEST (bSQL) | Blockpoint Docs

Reads data digests from the specified database object. For examples, see Examples

bSQL Syntax Conventions

Syntax​

READ DIGEST { <datbase_object> }

database_object ::=
{
database_name.blockchain_name
| datbase_name
}

Arguments​

database_name
The target database to read the digests.

blockchain_name
The target blockchain to read the digests from.

Permissions​

Requires READ permissions on the target blockchain(s).

READ permissions on all blockchains default to members of the admin fixed database role. READ permissions on user-defined blockchains default to the developer and reader fixed database roles. Members of the admin role can transfer permissions to other users.

Remarks​

  • The READ DIGEST command reads page hashes, timestamps, and previous hashes and outputs the data in query format. The command returns a response with the following columns:

    - **blockchain_id**: The internal id of the blockchain.
    - **page_id**: The page id of the blockchain.
    - **timestamp**: The time that the page was sealed at.
    - **current_hash**: The hash of that page as a UINT64.
    - **previous_hash**: The hash of the previous page (*page_id* - 1); stored as 0 for the first page in the blockchain.
  • Only blockchain pages in the archive are read. Blockchain pages are pushed to the archive when the page is full and no currently open transaction have written to that page. This ensures a ROLLBACK can't change archived data, resealing the page, and changing the hash.

  • Running a CHECK VALIDITY command before reading a digest ensures that digest is valid within the database and values haven't been illicitly changed.

Examples​

The following examples uses the Financial Demo Database.

A. Reading the digest from a blockchain​

The following example reads the digest from the pricing blockchain.

READ DIGEST financial.pricing;

Output​

The output returned reads the two archived pages in pricing, if there were no archived pages, no records would be returned. Notice that the previous hash of the first page is 0, because there is no previous page.

BLOCKCHAIN_ID [UINT16]  PAGE_ID [UINT64]    TIMESTAMP [TIMESTAMP]   CURRENT_HASH [UINT64]   PREVIOUS_HASH [UINT64]
19 0 2021-05-24 16:46:05.991142800 6006725463818420546 0
19 1 2021-05-24 16:46:05.992201900 3175351712536806224 6006725463818420546

B. Reading the digest from a database​

The following example reads all blockchain digests in the entire database.

READ DIGEST financial;

See Also​