aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-04-24 10:29:19 +0200
committerRiccardo Spagni <ric@spagni.net>2017-04-24 10:29:19 +0200
commita059e91d7fbdbf8745e48dd1c86e336483ff778c (patch)
tree27b42a557478acdee579b1f0ce649ca06218c1fc /src/cryptonote_basic
parentMerge pull request #1956 (diff)
parentSimplified the implementation and features of span (diff)
downloadmonero-a059e91d7fbdbf8745e48dd1c86e336483ff778c.tar.xz
Merge pull request #1816
93e10f1c Simplified the implementation and features of span (Lee Clagett) 4a8f96f9 Improvements for epee binary to hex functions: (Lee Clagett)
Diffstat (limited to 'src/cryptonote_basic')
-rw-r--r--src/cryptonote_basic/cryptonote_basic.h1
-rw-r--r--src/cryptonote_basic/cryptonote_basic_impl.h39
2 files changed, 23 insertions, 17 deletions
diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h
index 15ace2b0b..c4adf1fcb 100644
--- a/src/cryptonote_basic/cryptonote_basic.h
+++ b/src/cryptonote_basic/cryptonote_basic.h
@@ -44,7 +44,6 @@
#include "serialization/debug_archive.h"
#include "serialization/crypto.h"
#include "serialization/keyvalue_serialization.h" // eepe named serialization
-#include "string_tools.h"
#include "cryptonote_config.h"
#include "crypto/crypto.h"
#include "crypto/hash.h"
diff --git a/src/cryptonote_basic/cryptonote_basic_impl.h b/src/cryptonote_basic/cryptonote_basic_impl.h
index 4e1468510..14c03ac4c 100644
--- a/src/cryptonote_basic/cryptonote_basic_impl.h
+++ b/src/cryptonote_basic/cryptonote_basic_impl.h
@@ -33,6 +33,8 @@
#include "cryptonote_basic.h"
#include "crypto/crypto.h"
#include "crypto/hash.h"
+#include "hex.h"
+#include "span.h"
namespace cryptonote {
@@ -123,23 +125,28 @@ namespace cryptonote {
bool operator ==(const cryptonote::block& a, const cryptonote::block& b);
}
-template <class T>
-std::ostream &print256(std::ostream &o, const T &v) {
- return o << "<" << epee::string_tools::pod_to_hex(v) << ">";
-}
-template <class T>
-std::ostream &print64(std::ostream &o, const T &v) {
- return o << "<" << epee::string_tools::pod_to_hex(v) << ">";
-}
-
bool parse_hash256(const std::string str_hash, crypto::hash& hash);
namespace crypto {
- inline std::ostream &operator <<(std::ostream &o, const crypto::public_key &v) { return print256(o, v); }
- inline std::ostream &operator <<(std::ostream &o, const crypto::secret_key &v) { return print256(o, v); }
- inline std::ostream &operator <<(std::ostream &o, const crypto::key_derivation &v) { return print256(o, v); }
- inline std::ostream &operator <<(std::ostream &o, const crypto::key_image &v) { return print256(o, v); }
- inline std::ostream &operator <<(std::ostream &o, const crypto::signature &v) { return print256(o, v); }
- inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) { return print256(o, v); }
- inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) { return print64(o, v); }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::public_key &v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::secret_key &v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::key_derivation &v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::key_image &v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::signature &v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
+ epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
+ }
}