CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
53 std::shared_ptr<const model::Block>
loadBlock(
Height height)
const override;
58 void purge()
override;
66 explicit HashFile(
const std::string& dataDirectory);
uint64_t get() const
Gets the index value.
Definition: IndexFile.cpp:36
File-based block storage.
Definition: FileBlockStorage.h:39
std::pair< std::vector< uint8_t >, bool > loadBlockStatementData(Height height) const override
Returns the optional block statement data at height.
Definition: FileBlockStorage.cpp:300
Provides a buffered output stream around raw file.
Definition: BufferedFileStream.h:32
Wrapper for low-level i/o operations on files.
Definition: RawFile.h:49
Open file for both reading and writing. Removes the file if it exists.
Index file containing a uint64_t value.
Definition: IndexFile.h:28
Hash256 EntityHash
Entity hash.
Definition: Elements.h:66
Maintain hash-based index.
utils::BaseValue< uint64_t, Height_tag > Height
Definition: src/catapult/types.h:85
void purge() override
Purges all blocks from storage.
Definition: FileBlockStorage.cpp:317
Open file in read-only mode.
void seek(uint64_t position)
Definition: RawFile.cpp:320
const model::Block & Block
Block entity.
Definition: Elements.h:63
void dropBlocksAfter(Height height) override
Drops all blocks after height.
Definition: FileBlockStorage.cpp:245
Definition: FileBlockStorage.h:64
std::string m_dataDirectory
Definition: FileBlockStorage.h:80
Definition: IoThreadPool.h:25
IndexFile m_indexFile
Definition: FileBlockStorage.h:84
Interface that allows saving, loading and pruning blocks.
Definition: BlockStorage.h:63
OpenMode
Defines mode of opening the file.
Definition: RawFile.h:28
void reset()
Definition: FileBlockStorage.cpp:155
Represents a range of entities.
Definition: EntityRange.h:31
auto Read32(TIo &input)
Reads value from input.
Definition: PodIoUtils.h:74
RawFile & m_rawFile
Definition: FileBlockStorage.cpp:193
constexpr ValueType unwrap() const
Unwraps this value and returns the underlying raw value.
Definition: BaseValue.h:53
HashFile m_hashFile
Definition: FileBlockStorage.h:83
void WriteBlockStatement(const model::BlockStatement &blockStatement, OutputStream &outputStream)
Writes blockStatement into outputStream.
Definition: BlockStatementSerializer.cpp:65
BasicRawBuffer< uint8_t > MutableRawBuffer
A mutable binary buffer.
Definition: RawBuffer.h:65
uint64_t m_cachedDirectoryId
Definition: FileBlockStorage.h:76
std::shared_ptr< const model::Block > loadBlock(Height height) const override
Returns the block at height.
Definition: FileBlockStorage.cpp:282
#define CATAPULT_THROW_RUNTIME_ERROR_1(MESSAGE, PARAM1)
Macro used to throw a catapult runtime error with a single parameter.
Definition: exceptions.h:171
FileBlockStorageMode
File block storage modes.
Definition: FileBlockStorage.h:30
static EntityRange PrepareFixed(size_t numElements, uint8_t **ppRangeData=nullptr)
Definition: EntityRange.h:265
void requireHeight(Height height, const char *description) const
Definition: FileBlockStorage.cpp:327
model::HashRange loadHashesFrom(Height height, size_t maxHashes) const override
Returns a range of at most maxHashes hashes starting at height.
Definition: FileBlockStorage.cpp:201
void saveBlock(const model::BlockElement &blockElement) override
Saves blockElement.
Definition: FileBlockStorage.cpp:214
void flush() override
Definition: BufferedFileStream.cpp:33
FileBlockStorage(const std::string &dataDirectory, FileBlockStorageMode mode=FileBlockStorageMode::Hash_Index)
Definition: FileBlockStorage.cpp:164
std::unique_ptr< RawFile > m_pCachedHashFile
Definition: FileBlockStorage.h:77
uint64_t size
Definition: MemoryCounters.cpp:65
void PurgeDirectory(const std::string &directory)
Deletes everything in directory but does not delete the directory itself.
Definition: FilesystemUtils.cpp:26
void save(Height height, const Hash256 &hash)
Definition: FileBlockStorage.cpp:144
EntityRange< Hash256 > HashRange
An entity range composed of hashes.
Definition: RangeTypes.h:35
std::shared_ptr< model::BlockElement > ReadBlockElement(InputStream &inputStream)
Definition: BlockElementSerializer.cpp:110
void WriteBlockElement(const model::BlockElement &blockElement, OutputStream &outputStream)
Writes blockElement into outputStream.
Definition: BlockElementSerializer.cpp:51
void set(uint64_t value)
Sets the index value to value.
Definition: IndexFile.cpp:41
HashFile(const std::string &dataDirectory)
Definition: FileBlockStorage.cpp:101
Processing element for a block composed of a block and metadata.
Definition: Elements.h:55
Height chainHeight() const override
Gets the number of blocks.
Definition: FileBlockStorage.cpp:197
#define SPRINTF
Definition: FileBlockStorage.cpp:45
bool exists() const
true if the index file exists.
Definition: IndexFile.cpp:32
model::HashRange loadHashesFrom(Height height, size_t numHashes) const
Definition: FileBlockStorage.cpp:123
#define CATAPULT_THROW_INVALID_ARGUMENT(MESSAGE)
Macro used to throw a catapult invalid argument.
Definition: exceptions.h:179
Open file for both reading and writing.
Definition: AddressExtractionExtension.cpp:28
config::CatapultDataDirectory m_dataDirectory
Definition: FileSpoolingExtension.cpp:44
constexpr size_t Hash256_Size
Definition: src/catapult/types.h:34
const std::string & m_dataDirectory
Definition: FileBlockStorage.h:73
std::shared_ptr< const model::BlockElement > loadBlockElement(Height height) const override
Returns the block element (owning a block) at height.
Definition: FileBlockStorage.cpp:288
FileBlockStorageMode m_mode
Definition: FileBlockStorage.h:81
Writer interface.
Definition: Stream.h:41
BasicRawBuffer< const uint8_t > RawBuffer
A const binary buffer.
Definition: RawBuffer.h:62
std::shared_ptr< const BlockStatement > OptionalStatement
Definition: Elements.h:79