sqlite wrapper for ledger database. (#228)

Added wrapper methods to create ledger table and insert records for sqlite database.
This commit is contained in:
adheeb-adb
2021-01-29 18:06:31 +05:30
committed by GitHub
parent 3d36912c25
commit 62c91ad90c
11 changed files with 522 additions and 2 deletions

View File

@@ -175,6 +175,28 @@ namespace crypto
return hash;
}
/**
* Generates blake3 hash for the given string set using stream hashing.
*/
std::string get_hash(const std::set<std::string> &sw_set)
{
std::string hash;
hash.resize(BLAKE3_OUT_LEN);
// Init stream hashing.
blake3_hasher hasher;
blake3_hasher_init(&hasher);
// Hash is generated only using message in contract output struct.
for (std::string_view sw : sw_set)
blake3_hasher_update(&hasher, reinterpret_cast<const unsigned char *>(sw.data()), sw.length());
// Get the final hash.
blake3_hasher_finalize(&hasher, reinterpret_cast<unsigned char *>(hash.data()), hash.length());
return hash;
}
std::string generate_uuid()
{
std::string rand_bytes;