CatapultServer  v0.5.0.1 (Elephant)
catapult::extensions::MemoryBlockStorage Class Reference

A memory-based block storage that loads and saves blocks in memory. More...

Inheritance diagram for catapult::extensions::MemoryBlockStorage:
Collaboration diagram for catapult::extensions::MemoryBlockStorage:

Public Member Functions

 MemoryBlockStorage (const model::BlockElement &nemesisBlockElement)
 Creates a memory-based block storage around nemesisBlockElement. More...
 
Height chainHeight () const override
 Gets the number of blocks. More...
 
model::HashRange loadHashesFrom (Height height, size_t maxHashes) const override
 Returns a range of at most maxHashes hashes starting at height. More...
 
void saveBlock (const model::BlockElement &blockElement) override
 Saves blockElement. More...
 
void dropBlocksAfter (Height height) override
 Drops all blocks after height. More...
 
std::shared_ptr< const model::BlockloadBlock (Height height) const override
 Returns the block at height. More...
 
std::shared_ptr< const model::BlockElementloadBlockElement (Height height) const override
 Returns the block element (owning a block) at height. More...
 
std::pair< std::vector< uint8_t >, bool > loadBlockStatementData (Height height) const override
 Returns the optional block statement data at height. More...
 
void purge () override
 Purges all blocks from storage. More...
 
- Public Member Functions inherited from catapult::io::LightBlockStorage
virtual ~LightBlockStorage ()=default
 
- Public Member Functions inherited from catapult::utils::NonCopyable
constexpr NonCopyable ()=default
 Default constructor. More...
 
 ~NonCopyable ()=default
 Default destructor. More...
 
 NonCopyable (const NonCopyable &)=delete
 Disabled copy constructor. More...
 
NonCopyableoperator= (const NonCopyable &)=delete
 Disabled assignment operator. More...
 

Private Types

using Blocks = std::map< Height, std::shared_ptr< model::Block > >
 
using BlockElements = std::map< Height, std::shared_ptr< model::BlockElement > >
 
using BlockStatements = std::map< Height, std::shared_ptr< const model::BlockStatement > >
 

Private Member Functions

void requireHeight (Height height, const char *description) const
 

Private Attributes

Blocks m_blocks
 
BlockElements m_blockElements
 
BlockStatements m_blockStatements
 
Height m_height
 

Detailed Description

A memory-based block storage that loads and saves blocks in memory.

Member Typedef Documentation

◆ BlockElements

◆ Blocks

using catapult::extensions::MemoryBlockStorage::Blocks = std::map<Height, std::shared_ptr<model::Block> >
private

◆ BlockStatements

Constructor & Destructor Documentation

◆ MemoryBlockStorage()

catapult::extensions::MemoryBlockStorage::MemoryBlockStorage ( const model::BlockElement nemesisBlockElement)
explicit

Creates a memory-based block storage around nemesisBlockElement.

Here is the call graph for this function:

Member Function Documentation

◆ chainHeight()

Height catapult::extensions::MemoryBlockStorage::chainHeight ( ) const
overridevirtual

Gets the number of blocks.

Implements catapult::io::LightBlockStorage.

Here is the caller graph for this function:

◆ dropBlocksAfter()

void catapult::extensions::MemoryBlockStorage::dropBlocksAfter ( Height  height)
overridevirtual

Drops all blocks after height.

Implements catapult::io::LightBlockStorage.

◆ loadBlock()

std::shared_ptr< const model::Block > catapult::extensions::MemoryBlockStorage::loadBlock ( Height  height) const
overridevirtual

Returns the block at height.

Implements catapult::io::BlockStorage.

Here is the call graph for this function:

◆ loadBlockElement()

std::shared_ptr< const model::BlockElement > catapult::extensions::MemoryBlockStorage::loadBlockElement ( Height  height) const
overridevirtual

Returns the block element (owning a block) at height.

Implements catapult::io::BlockStorage.

Here is the call graph for this function:

◆ loadBlockStatementData()

std::pair< std::vector< uint8_t >, bool > catapult::extensions::MemoryBlockStorage::loadBlockStatementData ( Height  height) const
overridevirtual

Returns the optional block statement data at height.

Implements catapult::io::BlockStorage.

Here is the call graph for this function:

◆ loadHashesFrom()

model::HashRange catapult::extensions::MemoryBlockStorage::loadHashesFrom ( Height  height,
size_t  maxHashes 
) const
overridevirtual

Returns a range of at most maxHashes hashes starting at height.

Implements catapult::io::LightBlockStorage.

Here is the call graph for this function:

◆ purge()

void catapult::extensions::MemoryBlockStorage::purge ( )
overridevirtual

Purges all blocks from storage.

Implements catapult::io::PrunableBlockStorage.

◆ requireHeight()

void catapult::extensions::MemoryBlockStorage::requireHeight ( Height  height,
const char *  description 
) const
private
Here is the caller graph for this function:

◆ saveBlock()

void catapult::extensions::MemoryBlockStorage::saveBlock ( const model::BlockElement blockElement)
overridevirtual

Saves blockElement.

Implements catapult::io::LightBlockStorage.

Here is the caller graph for this function:

Member Data Documentation

◆ m_blockElements

BlockElements catapult::extensions::MemoryBlockStorage::m_blockElements
private

◆ m_blocks

Blocks catapult::extensions::MemoryBlockStorage::m_blocks
private

◆ m_blockStatements

BlockStatements catapult::extensions::MemoryBlockStorage::m_blockStatements
private

◆ m_height

Height catapult::extensions::MemoryBlockStorage::m_height
private

The documentation for this class was generated from the following files: