6 #ifndef KAGOME_INHERENT_DATA_HPP 7 #define KAGOME_INHERENT_DATA_HPP 12 #include <boost/iterator_adaptors.hpp> 18 #include "scale/scale.hpp" 19 #include "scale/scale_error.hpp" 55 return outcome::success();
66 data[identifier] =
common::Buffer(scale::encode(inherent).value());
74 auto inherent = data.find(identifier);
75 if (inherent != data.end()) {
76 auto buf = inherent->second;
77 return scale::decode<T>(buf);
86 std::map<InherentIdentifier, common::Buffer>
data;
97 typename = std::enable_if_t<Stream::is_encoder_stream>>
99 const auto &data = v.
data;
100 std::vector<std::pair<InherentIdentifier, common::Buffer>> vec;
101 vec.reserve(data.size());
102 for (
auto &pair : data) {
103 vec.emplace_back(pair);
117 typename = std::enable_if_t<Stream::is_decoder_stream>>
119 std::vector<std::pair<InherentIdentifier, common::Buffer>> vec;
122 for (
const auto &item : vec) {
124 if (v.
data.find(item.first) != v.
data.end()) {
134 #endif // KAGOME_INHERENT_DATA_HPP Class represents arbitrary (including empty) byte buffer.
void raise(T t)
throws outcome::result error as boost exception
OUTCOME_HPP_DECLARE_ERROR(kagome::primitives, InherentDataError)
std::map< InherentIdentifier, common::Buffer > data
Stream & operator>>(Stream &s, ArithmeticError &v)
void replaceData(InherentIdentifier identifier, const T &inherent)
SLBuffer< std::numeric_limits< size_t >::max()> Buffer
outcome::result< T > getData(const InherentIdentifier &identifier) const
bool operator==(const Transaction &v1, const Transaction &v2)
Stream & operator<<(Stream &s, const ArithmeticError &v)
libp2p::connection::Stream Stream
InherentDataError
inherent data encode/decode error codes
outcome::result< void > putData(InherentIdentifier identifier, const T &inherent)