src/blockchain/impl/common.hpp¶
Namespaces¶
| Name |
|---|
| sgns |
| sgns::blockchain |
Types¶
| Name | |
|---|---|
| enum class | Error |
| using storage::face::Readable< base::Buffer, base::Buffer > | ReadableBufferMap |
Functions¶
| Name | |
|---|---|
| outcome::result< base::Buffer > | idToBufferKey(crdt::GlobalDB & db, const primitives::BlockId & id) |
| outcome::result< std::string > | idToStringKey(crdt::GlobalDB & db, const primitives::BlockId & id) |
| base::Buffer | trieRoot(const std::vector< std::pair< base::Buffer, base::Buffer > > & key_vals) |
Types Documentation¶
enum Error¶
| Enumerator | Value | Description |
|---|---|---|
| BLOCK_NOT_FOUND | 1 |
using ReadableBufferMap¶
Functions Documentation¶
function idToBufferKey¶
outcome::result< base::Buffer > idToBufferKey(
crdt::GlobalDB & db,
const primitives::BlockId & id
)
Convert a block ID into a key, which is a first part of a key, by which the columns are stored in the database
function idToStringKey¶
Convert a block ID into a key, which is a first part of a key, by which the columns are stored in the database
function trieRoot¶
Parameters:
- key_vals pairs and
Return: Buffer containing merkle root of resulting trie
Instantiate empty merkle trie, insert
Source code¶
#ifndef SUPERGENIUS_BLOCKCHAIN_COMMON_HPP
#define SUPERGENIUS_BLOCKCHAIN_COMMON_HPP
#include "outcome/outcome.hpp"
#include "base/buffer.hpp"
#include "primitives/block_id.hpp"
#include "crdt/globaldb/globaldb.hpp"
namespace sgns::blockchain {
using ReadableBufferMap =
storage::face::Readable<base::Buffer, base::Buffer>;
enum class Error {
// it's important to convert storage errors of this type to this one to
// enable a user to discern between cases when a header with provided id
// is not found and when an internal storage error occurs
BLOCK_NOT_FOUND = 1
};
outcome::result<base::Buffer> idToBufferKey(crdt::GlobalDB &db,
const primitives::BlockId &id);
outcome::result<std::string> idToStringKey(crdt::GlobalDB &db,
const primitives::BlockId &id);
base::Buffer trieRoot(
const std::vector<std::pair<base::Buffer, base::Buffer>> &key_vals);
} // namespace sgns::blockchain
OUTCOME_HPP_DECLARE_ERROR_2(sgns::blockchain, Error)
#endif // SUPERGENIUS_BLOCKCHAIN_COMMON_HPP
Updated on 2026-03-04 at 13:10:44 -0800