21 return "Invalid storage key";
23 return "Unknown error";
33 return map.
put(num_to_idx_key, block_lookup_key);
44 OUTCOME_TRY(map.
put(hash_to_idx_key, block_lookup_key));
46 auto value_lookup_key =
prependPrefix(block_lookup_key, prefix);
48 return map.
put(value_lookup_key, value);
55 if (!key.has_value())
return false;
64 if (!key.has_value())
return std::nullopt;
70 BOOST_ASSERT((n & 0xffffffff00000000) == 0);
72 return {uint8_t(n >> 24u),
73 uint8_t((n >> 16u) & 0xffu),
74 uint8_t((n >> 8u) & 0xffu),
90 return (uint64_t(key[0]) << 24u) | (uint64_t(key[1]) << 16u)
91 | (uint64_t(key[2]) << 8u) | uint64_t(key[3]);
Class represents arbitrary (including empty) byte buffer.
outcome::result< primitives::BlockNumber > lookupKeyToNumber(const common::BufferView &key)
common::Buffer numberAndHashToLookupKey(primitives::BlockNumber number, const common::Hash256 &hash)
outcome::result< std::optional< common::Buffer > > idToLookupKey(const ReadableBufferStorage &map, const primitives::BlockId &id)
common::Buffer numberToIndexKey(primitives::BlockNumber n)
outcome::result< void > putWithPrefix(storage::BufferStorage &map, prefix::Prefix prefix, BlockNumber num, Hash256 block_hash, const common::Buffer &value)
outcome::result< void > putNumberToIndexKey(storage::BufferStorage &map, const primitives::BlockInfo &block)
SLBuffer< std::numeric_limits< size_t >::max()> Buffer
SLBuffer & put(std::string_view view)
Put a string into byte buffer.
primitives::BlockNumber BlockNumber
SLBuffer & reserve(size_t size)
outcome::result< std::optional< common::Buffer > > getWithPrefix(const storage::BufferStorage &map, prefix::Prefix prefix, const primitives::BlockId &block_id)
virtual outcome::result< void > put(const K &key, const V &value)=0
Store value by key.
virtual outcome::result< bool > contains(const Key &key) const =0
Checks if given key-value binding exists in the storage.
boost::variant< BlockHash, BlockNumber > BlockId
Block id is the variant over BlockHash and BlockNumber.
outcome::result< bool > hasWithPrefix(const storage::BufferStorage &map, prefix::Prefix prefix, const primitives::BlockId &block_id)
OUTCOME_CPP_DEFINE_CATEGORY(kagome::blockchain, KeyValueRepositoryError, e)
common::Buffer prependPrefix(common::BufferView key, prefix::Prefix key_column)
virtual outcome::result< std::optional< V > > tryLoad(const Key &key) const =0
Load value by key.