CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
25 namespace catapult {
namespace io {
struct CachedData; } }
78 void saveBlocks(
const std::vector<model::BlockElement>& blockElements);
100 BlockStorageCache(std::unique_ptr<BlockStorage>&& pStorage, std::unique_ptr<PrunableBlockStorage>&& pStagingStorage);
BlockStorageCache(std::unique_ptr< BlockStorage > &&pStorage, std::unique_ptr< PrunableBlockStorage > &&pStagingStorage)
Creates a new cache around pStorage that uses pStagingStorage for staging blocks in order to enable t...
Definition: BlockStorageCache.cpp:167
virtual std::shared_ptr< const model::Block > loadBlock(Height height) const =0
Returns the block at height.
CachedData & m_cachedData
Definition: BlockStorageCache.h:91
BlockStorageView(const BlockStorage &storage, utils::SpinReaderWriterLock::ReaderLockGuard &&readLock, const CachedData &cachedData)
Creates a view around storage and cache data (cachedData) with lock context readLock.
Definition: BlockStorageCache.cpp:72
utils::SpinReaderWriterLock::ReaderLockGuard m_readLock
Definition: BlockStorageCache.h:59
std::shared_ptr< const model::Block > block(Height) const
Definition: BlockStorageCache.cpp:42
const CachedData & m_cachedData
Definition: BlockStorageCache.h:60
void saveBlocks(const std::vector< model::BlockElement > &blockElements)
Saves multiple block elements (blockElements).
Definition: BlockStorageCache.cpp:141
utils::SpinReaderWriterLock::WriterLockGuard m_writeLock
Definition: BlockStorageCache.h:90
Height m_saveStartHeight
Definition: BlockStorageCache.h:92
std::unique_ptr< PrunableBlockStorage > m_pStagingStorage
Definition: BlockStorageCache.h:114
virtual std::pair< std::vector< uint8_t >, bool > loadBlockStatementData(Height height) const =0
Returns the optional block statement data at height.
BlockStorageModifier(BlockStorage &storage, PrunableBlockStorage &stagingStorage, utils::SpinReaderWriterLock::ReaderLockGuard &&readLock, CachedData &cachedData)
Creates a view around storage, stagingStorage and cache data (cachedData) with lock context readLock.
Definition: BlockStorageCache.cpp:124
A write only view on top of block storage.
Definition: BlockStorageCache.h:64
utils::BaseValue< uint64_t, Height_tag > Height
Definition: src/catapult/types.h:85
virtual std::shared_ptr< const model::BlockElement > loadBlockElement(Height height) const =0
Returns the block element (owning a block) at height.
virtual model::HashRange loadHashesFrom(Height height, size_t maxHashes) const =0
Returns a range of at most maxHashes hashes starting at height.
std::shared_ptr< const model::Block > loadBlock(Height height) const
Returns the block at height.
Definition: BlockStorageCache.cpp:89
model::HashRange loadHashesFrom(Height height, size_t maxHashes) const
Returns a range of at most maxHashes hashes starting at height.
Definition: BlockStorageCache.cpp:85
utils::SpinReaderWriterLock::ReaderLockGuard m_readLock
Definition: MemoryPtCache.cpp:258
std::shared_ptr< const model::BlockElement > loadBlockElement(Height height) const
Returns the block element (owning a block) at height.
Definition: BlockStorageCache.cpp:97
const io::BlockStorageCache & m_storage
Definition: LocalChainApi.cpp:57
Interface that allows saving, loading and pruning blocks.
Definition: BlockStorage.h:63
A read only view on top of block storage.
Definition: BlockStorageCache.h:30
Represents a range of entities.
Definition: EntityRange.h:31
BlockStorageModifier modifier()
Gets a write only view of the storage.
Definition: BlockStorageCache.cpp:180
void saveBlock(const model::BlockElement &blockElement)
Saves a block element (blockElement).
Definition: BlockStorageCache.cpp:137
utils::SpinReaderWriterLock::ReaderLockGuard m_readLock
Definition: BlockStorageCache.h:89
void dropBlocksAfter(Height height)
Drops all blocks after height.
Definition: BlockStorageCache.cpp:146
ReaderLockGuard acquireReader()
Blocks until a reader lock can be acquired.
Definition: SpinReaderWriterLock.h:153
BlockStorageView view() const
Gets a read only view of the storage.
Definition: BlockStorageCache.cpp:176
void update(const std::shared_ptr< const model::BlockElement > &pBlockElement)
Definition: BlockStorageCache.cpp:56
virtual void dropBlocksAfter(Height height)=0
Drops all blocks after height.
A writer lock guard.
Definition: SpinReaderWriterLock.h:83
void MoveBlockFiles(PrunableBlockStorage &sourceStorage, BlockStorage &destinationStorage, Height startHeight)
Moves block files starting at startHeight from sourceStorage to destinationStorage.
Definition: MoveBlockFiles.cpp:28
void requireHeight(Height height, const char *description) const
Definition: BlockStorageCache.cpp:110
virtual Height chainHeight() const =0
Gets the number of blocks.
utils::SpinReaderWriterLock::WriterLockGuard m_writeLock
Definition: MemoryPtCache.cpp:259
Definition: BlockStorageCache.h:97
std::unique_ptr< CachedData > m_pCachedData
Definition: BlockStorageCache.h:115
Height chainHeight() const
Gets the number of blocks.
Definition: BlockStorageCache.cpp:81
BlockStorage & m_storage
Definition: BlockStorageCache.h:87
void reset()
Definition: BlockStorageCache.cpp:60
A class that can be moved but not copied.
Definition: NonCopyable.h:43
const BlockStorage & m_storage
Definition: BlockStorageCache.h:58
std::pair< std::vector< uint8_t >, bool > loadBlockStatementData(Height height) const
Returns the optional block statement data at height.
Definition: BlockStorageCache.cpp:105
Processing element for a block composed of a block and metadata.
Definition: Elements.h:55
A reader lock guard.
Definition: SpinReaderWriterLock.h:99
Definition: BlockStorageCache.cpp:36
#define CATAPULT_THROW_INVALID_ARGUMENT(MESSAGE)
Macro used to throw a catapult invalid argument.
Definition: exceptions.h:179
Definition: AddressExtractionExtension.cpp:28
~BlockStorageCache()
Destroys the cache.
Height height() const
Definition: BlockStorageCache.cpp:38
Interface for saving and loading blocks.
Definition: BlockStorage.h:50
std::unique_ptr< BlockStorage > m_pStorage
Definition: BlockStorageCache.h:113
std::unique_ptr< BlockStorage > m_pStorage
Definition: AggregateBlockStorage.cpp:75
std::shared_ptr< const model::BlockElement > blockElement(Height) const
Definition: BlockStorageCache.cpp:46
std::shared_ptr< const model::BlockElement > m_pBlockElement
Definition: BlockStorageCache.cpp:65
utils::SpinReaderWriterLock m_lock
Definition: BlockStorageCache.h:116
Definition: SpinReaderWriterLock.h:36
void commit()
Commits all staged changes to the primary storage.
Definition: BlockStorageCache.cpp:151
PrunableBlockStorage & m_stagingStorage
Definition: BlockStorageCache.h:88
bool contains(Height height) const
Definition: BlockStorageCache.cpp:51
virtual void saveBlock(const model::BlockElement &blockElement)=0
Saves blockElement.