6 #ifndef KAGOME_ADAPTERS_PROTOBUF_STATE_RESPONSE 7 #define KAGOME_ADAPTERS_PROTOBUF_STATE_RESPONSE 12 #include "scale/scale.hpp" 22 static std::vector<uint8_t>::iterator
write(
24 std::vector<uint8_t> &out,
25 std::vector<uint8_t>::iterator loaded) {
26 ::api::v1::StateResponse msg;
27 for (
const auto &entries : t.
entries) {
28 auto *dst_entries = msg.add_entries();
29 dst_entries->set_state_root(entries.state_root.toString());
30 for (
const auto &entry : entries.entries) {
31 auto *dst_entry = dst_entries->add_entries();
32 dst_entry->set_key(entry.key.toString());
33 dst_entry->set_value(entry.value.toString());
35 dst_entries->set_complete(entries.complete);
42 static outcome::result<std::vector<uint8_t>::const_iterator>
read(
44 const std::vector<uint8_t> &src,
45 std::vector<uint8_t>::const_iterator from) {
46 const auto remains = src.size() - std::distance(src.begin(), from);
47 assert(remains >= size(out));
49 ::api::v1::StateResponse msg;
50 if (!msg.ParseFromArray(from.base(), remains))
53 for (
const auto &kvEntry : msg.entries()) {
59 for (
const auto &sEntry : kvEntry.entries()) {
65 out.
entries.emplace_back(std::move(kv));
69 std::advance(from, msg.ByteSizeLong());
76 #endif // KAGOME_ADAPTERS_PROTOBUF_STATE_RESPONSE Class represents arbitrary (including empty) byte buffer.
std::vector< uint8_t >::iterator appendToVec(const T &msg, std::vector< uint8_t > &out, std::vector< uint8_t >::iterator loaded)
common::Buffer proof
If no_proof is false in request, this contains proof nodes.
std::string toString() const
return content of bytearray as string
std::vector< StateEntry > entries
A collection of keys-values.
storage::trie::RootHash state_root
SLBuffer< std::numeric_limits< size_t >::max()> Buffer
static outcome::result< Blob< size_ > > fromString(std::string_view data)
SLBuffer & put(std::string_view view)
Put a string into byte buffer.
static outcome::result< std::vector< uint8_t >::const_iterator > read(StateResponse &out, const std::vector< uint8_t > &src, std::vector< uint8_t >::const_iterator from)
static size_t size(const StateResponse &t)
std::vector< KeyValueStateEntry > entries
static std::vector< uint8_t >::iterator write(const StateResponse &t, std::vector< uint8_t > &out, std::vector< uint8_t >::iterator loaded)
bool complete
Set to true when there are no more keys to return.