From c3aa901610fb132edc65ddd016e55c46b70540f5 Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Mon, 6 May 2024 15:12:22 -0300 Subject: [PATCH] Added no_discard to hasher --- src/crypto/hasher.hpp | 17 ++++++------ src/crypto/hasher/hasher_impl.hpp | 45 +++++++++++++++---------------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/crypto/hasher.hpp b/src/crypto/hasher.hpp index 514cee45..bcf2806f 100644 --- a/src/crypto/hasher.hpp +++ b/src/crypto/hasher.hpp @@ -4,7 +4,6 @@ #define SUPERGENIUS_SRC_HASHER_HASHER_HPP_ #include "base/blob.hpp" -#include "base/buffer.hpp" #include "integration/IComponent.hpp" namespace sgns::crypto { @@ -23,7 +22,7 @@ namespace sgns::crypto { * @return 128-bit hash value */ //------------ by ruymaster ----// - virtual Hash64 twox_64(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash64 twox_64( gsl::span buffer ) const = 0; /** * @brief twox_128 calculates 16-byte twox hash @@ -31,14 +30,14 @@ namespace sgns::crypto { * @return 128-bit hash value */ //------------ by ruymaster ----// - virtual Hash128 twox_128(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash128 twox_128( gsl::span buffer ) const = 0; /** * @brief blake2b_128 function calculates 16-byte blake2b hash * @param buffer source value * @return 128-bit hash value */ - virtual Hash128 blake2b_128(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash128 blake2b_128( gsl::span buffer ) const = 0; /** * @brief twox_256 calculates 32-byte twox hash @@ -46,35 +45,35 @@ namespace sgns::crypto { * @return 256-bit hash value */ //--------------------- - virtual Hash256 twox_256(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash256 twox_256( gsl::span buffer ) const = 0; /** * @brief blake2b_256 function calculates 32-byte blake2b hash * @param buffer source value * @return 256-bit hash value */ - virtual Hash256 blake2b_256(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash256 blake2b_256( gsl::span buffer ) const = 0; /** * @brief keccak_256 function calculates 32-byte keccak hash * @param buffer source value * @return 256-bit hash value */ - virtual Hash256 keccak_256(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash256 keccak_256( gsl::span buffer ) const = 0; /** * @brief blake2s_256 function calculates 32-byte blake2s hash * @param buffer source value * @return 256-bit hash value */ - virtual Hash256 blake2s_256(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash256 blake2s_256( gsl::span buffer ) const = 0; /** * @brief sha2_256 function calculates 32-byte sha2-256 hash * @param buffer source value * @return 256-bit hash value */ - virtual Hash256 sha2_256(gsl::span buffer) const = 0; + [[nodiscard]] virtual Hash256 sha2_256( gsl::span buffer ) const = 0; }; } // namespace sgns::crypto diff --git a/src/crypto/hasher/hasher_impl.hpp b/src/crypto/hasher/hasher_impl.hpp index 1f3eb2e4..90d86af3 100644 --- a/src/crypto/hasher/hasher_impl.hpp +++ b/src/crypto/hasher/hasher_impl.hpp @@ -1,39 +1,36 @@ - - #ifndef SUPERGENIUS_SRC_CRYPTO_HASHER_HASHER_IMPL_HPP_ #define SUPERGENIUS_SRC_CRYPTO_HASHER_HASHER_IMPL_HPP_ #include "crypto/hasher.hpp" -namespace sgns::crypto { - - class HasherImpl : public Hasher { - public: - ~HasherImpl() override = default; +namespace sgns::crypto +{ + class HasherImpl : public Hasher + { + public: + ~HasherImpl() override = default; -//----------------------------- - Hash64 twox_64(gsl::span buffer) const override; + [[nodiscard]] Hash64 twox_64( gsl::span buffer ) const override; - Hash128 twox_128(gsl::span buffer) const override; + [[nodiscard]] Hash128 twox_128( gsl::span buffer ) const override; - Hash128 blake2b_128(gsl::span buffer) const override; -//---------------------------- - Hash256 twox_256(gsl::span buffer) const override; + [[nodiscard]] Hash128 blake2b_128( gsl::span buffer ) const override; - Hash256 blake2b_256(gsl::span buffer) const override; + [[nodiscard]] Hash256 twox_256( gsl::span buffer ) const override; - Hash256 keccak_256(gsl::span buffer) const override; + [[nodiscard]] Hash256 blake2b_256( gsl::span buffer ) const override; - Hash256 blake2s_256(gsl::span buffer) const override; + [[nodiscard]] Hash256 keccak_256( gsl::span buffer ) const override; - Hash256 sha2_256(gsl::span buffer) const override; + [[nodiscard]] Hash256 blake2s_256( gsl::span buffer ) const override; - std::string GetName() override - { - return "HasherImpl"; - } - }; + [[nodiscard]] Hash256 sha2_256( gsl::span buffer ) const override; -} // namespace sgns::hash + std::string GetName() override + { + return "HasherImpl"; + } + }; +} -#endif // SUPERGENIUS_SRC_CRYPTO_HASHER_HASHER_IMPL_HPP_ +#endif