-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added macro for throw/assert of marshalling status #316
- Loading branch information
Showing
6 changed files
with
28 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
//---------------------------------------------------------------------------// | ||
// Copyright (c) 2021 Mikhail Komarov <[email protected]> | ||
// Copyright (c) 2021 Ilias Khairullin <[email protected]> | ||
// Copyright (c) 2024 Vasiliy Olekhov <[email protected]> | ||
// | ||
// MIT License | ||
// | ||
|
@@ -26,8 +27,6 @@ | |
#ifndef CRYPTO3_HASH_PEDERSEN_HPP | ||
#define CRYPTO3_HASH_PEDERSEN_HPP | ||
|
||
#include <tuple> | ||
|
||
#include <nil/crypto3/hash/accumulators/hash.hpp> | ||
#include <nil/crypto3/hash/algorithm/hash.hpp> | ||
#include <nil/crypto3/hash/hash_state.hpp> | ||
|
@@ -241,9 +240,9 @@ namespace nil { | |
static inline result_type process(internal_accumulator_type &acc) { | ||
auto result_point = nil::crypto3::accumulators::extract::hash<base_hash_type>(acc); | ||
nil::marshalling::status_type status; | ||
// TODO: check status | ||
result_type result = | ||
nil::marshalling::pack<typename construction::params_type::digest_endian>(result_point, status); | ||
THROW_IF_ERROR_STATUS(status, "Pedersen hash processing"); | ||
return result; | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
//---------------------------------------------------------------------------// | ||
// Copyright (c) 2017-2021 Mikhail Komarov <[email protected]> | ||
// Copyright (c) 2020-2021 Nikita Kaskov <[email protected]> | ||
// Copyright (c) 2024 Vasiliy Olekhov <[email protected]> | ||
// | ||
// MIT License | ||
// | ||
|
@@ -114,5 +115,18 @@ inline std::error_code make_error_code(nil::marshalling::status_type e) | |
return {static_cast<int>(e), category}; | ||
} | ||
|
||
#if defined(CRYPTO3_MARSHALLING_THROWS) | ||
|
||
#define THROW_IF_ERROR_STATUS(status, message) \ | ||
if (nil::marshalling::status_type::success != status) { \ | ||
std::stringstream os; os << std::string(message) << " " << make_error_code(status); \ | ||
throw std::invalid_argument(os); \ | ||
} | ||
|
||
#else | ||
|
||
#define THROW_IF_ERROR_STATUS(status, message) \ | ||
BOOST_VERIFY_MSG(nil::marshalling::status_type::success == status, message) | ||
#endif | ||
|
||
#endif // MARSHALLING_STATUS_TYPE_HPP |