mdbx++: переделка поддержки base58 по RFC-draft (backport).

This commit is contained in:
Леонид Юрьев (Leonid Yuriev)
2023-11-24 08:49:43 +03:00
parent 7fc6a1b658
commit 1277fe965d
2 changed files with 204 additions and 217 deletions

View File

@@ -1325,8 +1325,7 @@ struct LIBMDBX_API to_base58 {
/// \brief Returns the buffer size in bytes needed for
/// [Base58](https://en.wikipedia.org/wiki/Base58) dump of passed slice.
MDBX_CXX11_CONSTEXPR size_t envisage_result_length() const noexcept {
const size_t bytes =
source.length() / 8 * 11 + (source.length() % 8 * 43 + 31) / 32;
const size_t bytes = (source.length() * 11 + 7) / 8;
return wrap_width ? bytes + bytes / wrap_width : bytes;
}
@@ -1491,7 +1490,7 @@ struct LIBMDBX_API from_base58 {
/// [Base58](https://en.wikipedia.org/wiki/Base58) dump from a passed slice to
/// decoded data.
MDBX_CXX11_CONSTEXPR size_t envisage_result_length() const noexcept {
return source.length() / 11 * 8 + source.length() % 11 * 32 / 43;
return source.length() /* могут быть все нули кодируемые один-к-одному */;
}
/// \brief Fills the destination with data decoded from