ipfs-chromium
|
Immediate access to recently-accessed blocks. More...
#include <library/include/ipfs_client/block_storage.h>
Public Types | |
using | SerializedStorageHook = std::function< void(std::string, std::string, std::string)> |
Type for callbacks about new blocks. More... | |
Public Member Functions | |
BlockStorage (BlockStorage const &)=delete | |
bool | Store (std::string cid_str, Cid const &cid, std::string headers, std::string const &body, PbDag &&block) |
Store a Block for later access. More... | |
PbDag const * | Get (std::string const &cid) |
Get a block! More... | |
std::string const * | GetHeaders (std::string const &cid) |
Get HTTP headers associated with the block. More... | |
void | AddListening (UnixFsPathResolver *) |
Indicate that a particular path resolver is waiting on a CID to become available. | |
void | StopListening (UnixFsPathResolver *) |
Indicate that a particular path resolver is no longer waiting. | |
void | CheckListening () |
Normally called internally. More... | |
void | AddStorageHook (SerializedStorageHook) |
Register a callback that will be called when any new block goes into storage. | |
Store (Convenience) | |
Convenience functions for ipfs::BlockStorage::Store(std::string,Cid const&,std::string,std::string const&,Block&&) | |
bool | Store (std::string headers, std::string const &body, PbDag &&block) |
bool | Store (std::string const &cid, std::string headers, std::string body) |
bool | Store (std::string cid_str, Cid const &cid, std::string headers, std::string body) |
bool | Store (Cid const &cid, std::string headers, std::string const &body, PbDag &&) |
Immediate access to recently-accessed blocks.
Blocks are held in-memory, using pretty standard containers, as already-parsed ipfs::Block objects.
using ipfs::BlockStorage::SerializedStorageHook = std::function<void(std::string, std::string, std::string)> |
Type for callbacks about new blocks.
The parameters to the hook are
void ipfs::BlockStorage::CheckListening | ( | ) |
Normally called internally.
Checks to see if any listening path resolver appears to be waiting on a CID which is now available.
PbDag const* ipfs::BlockStorage::Get | ( | std::string const & | cid | ) |
Get a block!
cid must match string-wise exactly: same multibase & all. For identity codecs, returns the data even if not stored.
cid | - String representation of the CID for the block. |
std::string const* ipfs::BlockStorage::GetHeaders | ( | std::string const & | cid | ) |
Get HTTP headers associated with the block.
cid | - String representation of the CID for the block. |
bool ipfs::BlockStorage::Store | ( | std::string | cid_str, |
Cid const & | cid, | ||
std::string | headers, | ||
std::string const & | body, | ||
PbDag && | block | ||
) |
Store a Block for later access.
cid_str | - The string representation of cid |
cid | - The Content IDentifier |
headers | - Associated HTTP headers |
body | - The raw bytes of the block |
block | - The block being stored |