diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-08-19 13:39:33 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-08-19 14:20:15 +0200 |
commit | 44ddcd887ddf3f62bcfb9c0b59ba2124335dbe94 (patch) | |
tree | 6857630f21e38b5cb47052099c5e5b894a8d2f37 /src/base58.h | |
parent | c6532fa6c14d3cea5941cff9411937db9a8d5f1a (diff) | |
parent | 356988e200b1debaa80d210d502d2d085c72dc64 (diff) | |
download | bitcoin-44ddcd887ddf3f62bcfb9c0b59ba2124335dbe94.tar.xz |
Merge #19706: refactor: make EncodeBase58{Check} consume Spans
356988e200b1debaa80d210d502d2d085c72dc64 util: make EncodeBase58Check consume Spans (Sebastian Falbesoner)
f0fce0675d56b2226a993253731690ca864066c8 util: make EncodeBase58 consume Spans (Sebastian Falbesoner)
Pull request description:
This PR improves the interfaces for the functions `EncodeBase58{Check}` by using Spans, in a similar fashion to e.g. PRs #19660, #19687. Note that on the master branch there are currently two versions of `EncodeBase58`: one that takes two pointers (marking begin and end) and another one that takes a `std::vector<unsigned char>` const-ref. The PR branch only leaves one generic Span-interface, both simplifying the interface and allowing more generic containers to be passed. The same is done for `EncodeBase58Check`, where only one interface existed but it's more generic now (e.g. a std::array can be directly passed, as done in the benchmarks).
ACKs for top commit:
laanwj:
Code review ACK 356988e200b1debaa80d210d502d2d085c72dc64
Tree-SHA512: 47cfccdd7f3a2d4694bb8785e6e5fd756daee04ce1652ee59a7822e7e833b4a441ae9362b9bd67ea020d2b5b7d927629c9addb6abaa9881d8564fd3b1257f512
Diffstat (limited to 'src/base58.h')
-rw-r--r-- | src/base58.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/base58.h b/src/base58.h index 042ad671d3..b87664b78b 100644 --- a/src/base58.h +++ b/src/base58.h @@ -15,20 +15,15 @@ #define BITCOIN_BASE58_H #include <attributes.h> +#include <span.h> #include <string> #include <vector> /** - * Encode a byte sequence as a base58-encoded string. - * pbegin and pend cannot be nullptr, unless both are. + * Encode a byte span as a base58-encoded string */ -std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend); - -/** - * Encode a byte vector as a base58-encoded string - */ -std::string EncodeBase58(const std::vector<unsigned char>& vch); +std::string EncodeBase58(Span<const unsigned char> input); /** * Decode a base58-encoded string (psz) into a byte vector (vchRet). @@ -44,9 +39,9 @@ NODISCARD bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet, NODISCARD bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len); /** - * Encode a byte vector into a base58-encoded string, including checksum + * Encode a byte span into a base58-encoded string, including checksum */ -std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn); +std::string EncodeBase58Check(Span<const unsigned char> input); /** * Decode a base58-encoded string (psz) that includes a checksum into a byte |