hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
multihash.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_MULTIHASH_HPP
7 #define IROHA_MULTIHASH_HPP
8 
9 #include <cstdint>
10 #include <vector>
11 
12 #include "common/hexutils.hpp"
13 #include "common/result.hpp"
15 #include "multihash/type.hpp"
16 #include "multihash/varint.hpp"
17 
18 namespace iroha {
19  namespace multihash {
20 
26  struct Multihash {
29  };
30 
40 
48  template <typename Container>
49  inline void encodeVarIntType(Type multihash_type, Container &buffer) {
50  using NumberType = std::underlying_type_t<Type>;
51  encodeVarInt(static_cast<NumberType>(multihash_type), buffer);
52  }
53 
63  template <typename OutputContainer>
64  inline void encodeHexAppend(Type multihash_type,
66  OutputContainer &output) {
67  std::basic_string<std::byte> prefix_bin;
68  encodeVarIntType(multihash_type, prefix_bin);
69  encodeVarInt(input.size(), prefix_bin);
70 
73  prefix_bin.size()},
74  output);
76  }
77 
78  } // namespace multihash
79 } // namespace iroha
80 
81 #endif // IROHA_MULTIHASH_HPP
Type
https://github.com/multiformats/js-multihash/blob/master/src/constants.js
Definition: type.hpp:14
Definition: result_fwd.hpp:27
void encodeHexAppend(Type multihash_type, shared_model::interface::types::ByteRange input, OutputContainer &output)
Definition: multihash.hpp:64
shared_model::interface::types::ByteRange data
Definition: multihash.hpp:27
void bytestringToHexstringAppend(shared_model::interface::types::ByteRange input, OutputContainer &destination)
Definition: hexutils.hpp:36
Type type
Definition: multihash.hpp:28
Definition: block_query.hpp:15
Definition: multihash.hpp:26
void encodeVarIntType(Type multihash_type, Container &buffer)
Definition: multihash.hpp:49
std::basic_string_view< std::byte > ByteRange
Definition: byte_range.hpp:16
void encodeVarInt(NumberType number, Container &buffer)
Definition: varint.hpp:77
iroha::expected::Result< Multihash, const char * > createFromBuffer(ByteRange buffer)
Definition: multihash.cpp:13