sgns::blockchain::BlockHeaderRepository¶
#include <block_header_repository.hpp>
Inherits from IComponent
Inherited by sgns::blockchain::KeyValueBlockHeaderRepository
Public Functions¶
| Name | |
|---|---|
| virtual outcome::result< primitives::BlockNumber > | getNumberByHash(const base::Hash256 & hash) const =0 |
| virtual outcome::result< base::Hash256 > | getHashByNumber(const primitives::BlockNumber & number) const =0 |
| virtual outcome::result< primitives::BlockHeader > | getBlockHeader(const primitives::BlockId & id) const =0 |
| virtual outcome::result< primitives::BlockHash > | putBlockHeader(const primitives::BlockHeader & header) =0 |
| virtual outcome::result< void > | removeBlockHeader(const primitives::BlockId & id) =0 |
| virtual outcome::result< sgns::blockchain::BlockStatus > | getBlockStatus(const primitives::BlockId & id) const =0 |
| outcome::result< primitives::BlockNumber > | getNumberById(const primitives::BlockId & id) const |
| outcome::result< base::Hash256 > | getHashById(const primitives::BlockId & id) const |
Additional inherited members¶
Public Functions inherited from IComponent
| Name | |
|---|---|
| virtual | ~IComponent() =default |
| virtual std::string | GetName() =0 |
Detailed Description¶
An interface to a storage with block headers that provides several convenience methods, such as getting block number by its hash and vice versa or getting a block status
Public Functions Documentation¶
function getNumberByHash¶
virtual outcome::result< primitives::BlockNumber > getNumberByHash(
const base::Hash256 & hash
) const =0
Parameters:
- hash - a blake2_256 hash of an SCALE encoded block header
Return: the number of the block with the provided hash in case one is in the storage or an error
Reimplemented by: sgns::blockchain::KeyValueBlockHeaderRepository::getNumberByHash
function getHashByNumber¶
virtual outcome::result< base::Hash256 > getHashByNumber(
const primitives::BlockNumber & number
) const =0
Parameters:
- number - the number of a block, contained in a block header
Return: the hash of the block with the provided number in case one is in the storage or an error
Reimplemented by: sgns::blockchain::KeyValueBlockHeaderRepository::getHashByNumber
function getBlockHeader¶
virtual outcome::result< primitives::BlockHeader > getBlockHeader(
const primitives::BlockId & id
) const =0
Return: block header with corresponding id or an error
Reimplemented by: sgns::blockchain::KeyValueBlockHeaderRepository::getBlockHeader
function putBlockHeader¶
virtual outcome::result< primitives::BlockHash > putBlockHeader(
const primitives::BlockHeader & header
) =0
Reimplemented by: sgns::blockchain::KeyValueBlockHeaderRepository::putBlockHeader
function removeBlockHeader¶
Reimplemented by: sgns::blockchain::KeyValueBlockHeaderRepository::removeBlockHeader
function getBlockStatus¶
virtual outcome::result< sgns::blockchain::BlockStatus > getBlockStatus(
const primitives::BlockId & id
) const =0
Parameters:
- id of a block which status is returned
Return: status of a block or a storage error
Reimplemented by: sgns::blockchain::KeyValueBlockHeaderRepository::getBlockStatus
function getNumberById¶
Parameters:
- id of a block which number is returned
Return: block number or a none optional if the corresponding block header is not in storage or a storage error
function getHashById¶
Parameters:
- id of a block which hash is returned
Return: block hash or a none optional if the corresponding block header is not in storage or a storage error
Updated on 2026-03-04 at 13:10:43 -0800