Class BlockStorage

The main block storage handler class.

class BlockStorage ;

Methods

NameDescription
addBlock (Data) Adds a blocks to the storage. If the block already exists, the existing block's ID is returned instead without adding it again.
blockExists (Hash) Checks if a block exists using his hash.
deleteBlock (Index) Delete a block from this storage.
deleteBlock (Hash) Delete a block, using his hash as an identifier.
fastModeEnabled () Checks if the fast mode is enabled on this storage.
getAllBlocks () Return an array with hashes of the blocks of this storage. If the hash is empty, that means the block is deleted.
getBlock (Index) Return the entire block, including his data, using his ID.
getBlock (Hash) Return the entire block, including his data, using his hash.
getBlockSize () Returns the storage's max block size.
getUnusedBlocks () Returns the IDs of the currently deleted blocks.
getUsedBlocks () Returns only the currently used blocks of this storage.
hashToIndex (Hash) Search a block by his hash and return his ID.
healthCheck () Checks the entire storage's integrity, recalculating the block's hashes and comparing it with the hashes of the storage.
isLocked () Checks if there's an operation going on in this storage.
recover (Index) Marks again as used a block that has been previously deleted from the storage.