From f4866b777ef20dd13216a5d60480e070ebba9dc2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 16 Sep 2019 11:59:58 +0200 Subject: [PATCH] Move helper classes into fc::detail --- src/crypto/base58.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/crypto/base58.cpp b/src/crypto/base58.cpp index 929f387..cbe67a5 100644 --- a/src/crypto/base58.cpp +++ b/src/crypto/base58.cpp @@ -28,6 +28,8 @@ #include #include +namespace fc { namespace detail { + /** Errors thrown by the bignum class */ class bignum_error : public std::runtime_error { @@ -605,11 +607,10 @@ inline bool DecodeBase58(const std::string& str, std::vector& vch return DecodeBase58(str.c_str(), vchRet); } - -namespace fc { +} // detail std::string to_base58( const char* d, size_t s ) { - return EncodeBase58( (const unsigned char*)d, (const unsigned char*)d+s ).c_str(); + return fc::detail::EncodeBase58( (const unsigned char*)d, (const unsigned char*)d+s ).c_str(); } std::string to_base58( const std::vector& d ) @@ -620,8 +621,9 @@ std::string to_base58( const std::vector& d ) } std::vector from_base58( const std::string& base58_str ) { std::vector out; - if( !DecodeBase58( base58_str.c_str(), out ) ) { - FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", ("base58_str",base58_str) ); + if( !fc::detail::DecodeBase58( base58_str.c_str(), out ) ) { + FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", + ("base58_str",base58_str) ); } return std::vector((const char*)out.data(), ((const char*)out.data())+out.size() ); } @@ -629,10 +631,10 @@ std::vector from_base58( const std::string& base58_str ) { * @return the number of bytes decoded */ size_t from_base58( const std::string& base58_str, char* out_data, size_t out_data_len ) { - //slog( "%s", base58_str.c_str() ); std::vector out; - if( !DecodeBase58( base58_str.c_str(), out ) ) { - FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", ("base58_str",base58_str) ); + if( !fc::detail::DecodeBase58( base58_str.c_str(), out ) ) { + FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", + ("base58_str",base58_str) ); } FC_ASSERT( out.size() <= out_data_len ); if (!out.empty()) { @@ -640,6 +642,7 @@ size_t from_base58( const std::string& base58_str, char* out_data, size_t out_da } return out.size(); } -} + +} // fc #endif