hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
iroha::multihash Namespace Reference

Classes

struct  Multihash
 

Enumerations

enum  Type : uint64_t {
  sha1 = 0x11, sha256 = 0x12, sha512 = 0x13, blake2s128 = 0xb250,
  blake2s256 = 0xb260, ed25519pub = 0xed
}
 https://github.com/multiformats/js-multihash/blob/master/src/constants.js More...
 

Functions

iroha::expected::Result< Multihash, const char * > createFromBuffer (ByteRange buffer)
 
iroha::expected::Result< Multihash, const char * > createFromBuffer (shared_model::interface::types::ByteRange buffer)
 Creates a multihash from a binary buffer. The first bytes denote the data type, then goes the length, and the following are the data. More...
 
template<typename Container >
void encodeVarIntType (Type multihash_type, Container &buffer)
 
template<typename OutputContainer >
void encodeHexAppend (Type multihash_type, shared_model::interface::types::ByteRange input, OutputContainer &output)
 
template<typename NumberType >
bool readVarInt (shared_model::interface::types::ByteRange &buffer, NumberType &number)
 
template<typename NumberType , typename Container >
void encodeVarInt (NumberType number, Container &buffer)
 

Enumeration Type Documentation

◆ Type

enum iroha::multihash::Type : uint64_t

https://github.com/multiformats/js-multihash/blob/master/src/constants.js

Enumerator
sha1 
sha256 
sha512 
blake2s128 
blake2s256 
ed25519pub 

Function Documentation

◆ createFromBuffer() [1/2]

iroha::expected::Result<Multihash, const char *> iroha::multihash::createFromBuffer ( ByteRange  buffer)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFromBuffer() [2/2]

iroha::expected::Result<Multihash, const char *> iroha::multihash::createFromBuffer ( shared_model::interface::types::ByteRange  buffer)

Creates a multihash from a binary buffer. The first bytes denote the data type, then goes the length, and the following are the data.

Parameters
buffer- the buffer with the multihash
Returns
result with the multihash in case of success

◆ encodeHexAppend()

template<typename OutputContainer >
void iroha::multihash::encodeHexAppend ( Type  multihash_type,
shared_model::interface::types::ByteRange  input,
OutputContainer &  output 
)
inline

Encode data with its type in multihash format and write hex string of result to a buffer. https://github.com/multiformats/multihash

Template Parameters
OutputContainerdestination byte string container type
Parameters
[in]typeof data to encode
[in]inputbinary data to encode
[out]outputcontainer to write to
Here is the call graph for this function:
Here is the caller graph for this function:

◆ encodeVarInt()

template<typename NumberType , typename Container >
void iroha::multihash::encodeVarInt ( NumberType  number,
Container &  buffer 
)
inline

Append a single varint int to a buffer. https://github.com/multiformats/unsigned-varint#format

Template Parameters
NumberTypesome unsigned integer type
Containerdestination byte string container type
Parameters
[in]numberto encode
[out]bufferto write to
Here is the caller graph for this function:

◆ encodeVarIntType()

template<typename Container >
void iroha::multihash::encodeVarIntType ( Type  multihash_type,
Container &  buffer 
)
inline

Encode and append a multihash type to a buffer. https://github.com/multiformats/multihash

Template Parameters
Containerdestination byte string container type
Parameters
[in]typeto encode
[out]bufferto write to
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readVarInt()

template<typename NumberType >
bool iroha::multihash::readVarInt ( shared_model::interface::types::ByteRange buffer,
NumberType &  number 
)
inline

Try to read single varint int from buffer. https://github.com/multiformats/unsigned-varint#format

Template Parameters
NumberTypesome unsigned integer type
Parameters

How many varint bytes can a number of NumberType occupy. This is basically ceil(sizeof(number) * 8 / 7).

How much bytes are we going to read at most.

Here is the caller graph for this function: