mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Returned input hash and ledger info for input submissions. (#283)
- Introduced input hash which can later be used to query the ledger. - Returned input hash and ledger info at input submission. - Updated js client lib to support input hash. - Updated consensus proposal candidate expiration rules.
This commit is contained in:
@@ -154,14 +154,17 @@ namespace crypto
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates blake3 hash for the given string view vector using stream hashing.
|
||||
* Generates blake3 hash for the given list of strings using stream hashing.
|
||||
* @param str_list Any list container of list of strings or string_views.
|
||||
* @return The combined blake32 hash of elements in listed order.
|
||||
*/
|
||||
const std::string get_hash(const std::vector<std::string_view> &sw_vect)
|
||||
template <typename T>
|
||||
const std::string get_list_hash(const T &str_list)
|
||||
{
|
||||
std::string hash;
|
||||
hash.resize(BLAKE3_OUT_LEN);
|
||||
|
||||
if (sw_vect.empty())
|
||||
|
||||
if (str_list.empty())
|
||||
{
|
||||
return hash;
|
||||
}
|
||||
@@ -171,41 +174,17 @@ namespace crypto
|
||||
blake3_hasher_init(&hasher);
|
||||
|
||||
// Hash is generated only using message in contract output struct.
|
||||
for (std::string_view sw : sw_vect)
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates blake3 hash for the given string set using stream hashing.
|
||||
*/
|
||||
const std::string get_hash(const std::set<std::string> &sw_set)
|
||||
{
|
||||
std::string hash;
|
||||
hash.resize(BLAKE3_OUT_LEN);
|
||||
|
||||
if (sw_set.empty())
|
||||
{
|
||||
return hash;
|
||||
}
|
||||
|
||||
// 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());
|
||||
for (std::string_view sv : str_list)
|
||||
blake3_hasher_update(&hasher, reinterpret_cast<const unsigned char *>(sv.data()), sv.length());
|
||||
|
||||
// Get the final hash.
|
||||
blake3_hasher_finalize(&hasher, reinterpret_cast<unsigned char *>(hash.data()), hash.length());
|
||||
|
||||
return hash;
|
||||
}
|
||||
template const std::string get_list_hash<std::set<std::string>>(const std::set<std::string> &str_list);
|
||||
template const std::string get_list_hash<std::vector<std::string>>(const std::vector<std::string> &str_list);
|
||||
template const std::string get_list_hash<std::vector<std::string_view>>(const std::vector<std::string_view> &str_list);
|
||||
|
||||
const std::string generate_uuid()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user