aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-10 17:35:59 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-25 21:16:26 +0100
commit5d65a75b69e0e83e69384461f26111666d6bf9ae (patch)
tree9205cb60d67464ca5bfc299e8d658bfd4e6e21ae /src/crypto
parentMerge pull request #2466 (diff)
downloadmonero-5d65a75b69e0e83e69384461f26111666d6bf9ae.tar.xz
move checkpoints in a separate library
Diffstat (limited to '')
-rw-r--r--src/checkpoints/checkpoints.cpp (renamed from src/cryptonote_basic/checkpoints.cpp)3
-rw-r--r--src/checkpoints/checkpoints.h (renamed from src/cryptonote_basic/checkpoints.h)4
-rw-r--r--src/crypto/crypto.h22
-rw-r--r--src/crypto/hash.h13
-rw-r--r--src/cryptonote_basic/CMakeLists.txt3
-rw-r--r--src/cryptonote_basic/connection_context.h2
-rw-r--r--src/cryptonote_basic/cryptonote_basic.h5
-rw-r--r--src/cryptonote_basic/cryptonote_basic_impl.h25
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.cpp2
-rw-r--r--src/cryptonote_core/blockchain.cpp1
-rw-r--r--src/cryptonote_core/blockchain.h2
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp2
-rw-r--r--src/cryptonote_protocol/block_queue.cpp2
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl2
14 files changed, 46 insertions, 42 deletions
diff --git a/src/cryptonote_basic/checkpoints.cpp b/src/checkpoints/checkpoints.cpp
index 98e509561..60be7f7ec 100644
--- a/src/cryptonote_basic/checkpoints.cpp
+++ b/src/checkpoints/checkpoints.cpp
@@ -36,6 +36,7 @@ using namespace epee;
#include "common/dns_utils.h"
#include "include_base_utils.h"
+#include "storages/portable_storage_template_helper.h" // epee json include
#include <sstream>
#include <random>
@@ -51,7 +52,7 @@ namespace cryptonote
//---------------------------------------------------------------------------
bool checkpoints::add_checkpoint(uint64_t height, const std::string& hash_str)
{
- crypto::hash h = null_hash;
+ crypto::hash h = crypto::null_hash;
bool r = epee::string_tools::parse_tpod_from_hex_string(hash_str, h);
CHECK_AND_ASSERT_MES(r, false, "Failed to parse checkpoint hash string into binary representation!");
diff --git a/src/cryptonote_basic/checkpoints.h b/src/checkpoints/checkpoints.h
index 3a74d8a69..72eb232d7 100644
--- a/src/cryptonote_basic/checkpoints.h
+++ b/src/checkpoints/checkpoints.h
@@ -31,9 +31,9 @@
#pragma once
#include <map>
#include <vector>
-#include "cryptonote_basic_impl.h"
#include "misc_log_ex.h"
-#include "storages/portable_storage_template_helper.h" // epee json include
+#include "crypto/hash.h"
+#include "serialization/keyvalue_serialization.h"
#define ADD_CHECKPOINT(h, hash) CHECK_AND_ASSERT(add_checkpoint(h, hash), false);
#define JSON_HASH_FILE_NAME "checkpoints.json"
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index e99b6651f..94f924296 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -31,12 +31,16 @@
#pragma once
#include <cstddef>
+#include <iostream>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_guard.hpp>
+#include <boost/utility/value_init.hpp>
#include <vector>
#include "common/pod-class.h"
#include "generic-ops.h"
+#include "hex.h"
+#include "span.h"
#include "hash.h"
namespace crypto {
@@ -248,6 +252,24 @@ namespace crypto {
const signature *sig) {
return check_ring_signature(prefix_hash, image, pubs.data(), pubs.size(), sig);
}
+
+ 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;
+ }
+
+ const static crypto::public_key null_pkey = boost::value_initialized<crypto::public_key>();
}
CRYPTO_MAKE_HASHABLE(public_key)
diff --git a/src/crypto/hash.h b/src/crypto/hash.h
index 22991e513..610b4502f 100644
--- a/src/crypto/hash.h
+++ b/src/crypto/hash.h
@@ -31,9 +31,13 @@
#pragma once
#include <stddef.h>
+#include <iostream>
+#include <boost/utility/value_init.hpp>
#include "common/pod-class.h"
#include "generic-ops.h"
+#include "hex.h"
+#include "span.h"
namespace crypto {
@@ -75,6 +79,15 @@ namespace crypto {
tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
}
+ 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;
+ }
+
+ const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
+ const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
}
CRYPTO_MAKE_HASHABLE(hash)
diff --git a/src/cryptonote_basic/CMakeLists.txt b/src/cryptonote_basic/CMakeLists.txt
index 1503b277e..94da3bec8 100644
--- a/src/cryptonote_basic/CMakeLists.txt
+++ b/src/cryptonote_basic/CMakeLists.txt
@@ -34,7 +34,6 @@ endif()
set(cryptonote_basic_sources
account.cpp
- checkpoints.cpp
cryptonote_basic_impl.cpp
cryptonote_format_utils.cpp
difficulty.cpp
@@ -46,7 +45,6 @@ set(cryptonote_basic_headers)
set(cryptonote_basic_private_headers
account.h
account_boost_serialization.h
- checkpoints.h
connection_context.h
cryptonote_basic.h
cryptonote_basic_impl.h
@@ -69,6 +67,7 @@ target_link_libraries(cryptonote_basic
PUBLIC
common
cncrypto
+ checkpoints
${Boost_DATE_TIME_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
diff --git a/src/cryptonote_basic/connection_context.h b/src/cryptonote_basic/connection_context.h
index 3283543e2..da4b6512e 100644
--- a/src/cryptonote_basic/connection_context.h
+++ b/src/cryptonote_basic/connection_context.h
@@ -40,7 +40,7 @@ namespace cryptonote
struct cryptonote_connection_context: public epee::net_utils::connection_context_base
{
cryptonote_connection_context(): m_state(state_before_handshake), m_remote_blockchain_height(0), m_last_response_height(0),
- m_last_known_hash(cryptonote::null_hash) {}
+ m_last_known_hash(crypto::null_hash) {}
enum state
{
diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h
index c4adf1fcb..eb03d33b9 100644
--- a/src/cryptonote_basic/cryptonote_basic.h
+++ b/src/cryptonote_basic/cryptonote_basic.h
@@ -53,11 +53,6 @@
namespace cryptonote
{
-
- const static crypto::hash null_hash = AUTO_VAL_INIT(null_hash);
- const static crypto::hash8 null_hash8 = AUTO_VAL_INIT(null_hash8);
- const static crypto::public_key null_pkey = AUTO_VAL_INIT(null_pkey);
-
typedef std::vector<crypto::signature> ring_signature;
diff --git a/src/cryptonote_basic/cryptonote_basic_impl.h b/src/cryptonote_basic/cryptonote_basic_impl.h
index 7a2259b32..5523846d6 100644
--- a/src/cryptonote_basic/cryptonote_basic_impl.h
+++ b/src/cryptonote_basic/cryptonote_basic_impl.h
@@ -33,8 +33,6 @@
#include "cryptonote_basic.h"
#include "crypto/crypto.h"
#include "crypto/hash.h"
-#include "hex.h"
-#include "span.h"
namespace cryptonote {
@@ -136,26 +134,3 @@ namespace cryptonote {
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) {
- 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;
- }
-}
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index e73f5d778..fc979f288 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -632,7 +632,7 @@ namespace cryptonote
// prunable rct
if (t.rct_signatures.type == rct::RCTTypeNull)
{
- hashes[2] = cryptonote::null_hash;
+ hashes[2] = crypto::null_hash;
}
else
{
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index e1cc7361b..0b09d503c 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -49,7 +49,6 @@
#include "common/boost_serialization_helper.h"
#include "warnings.h"
#include "crypto/hash.h"
-#include "cryptonote_basic/checkpoints.h"
#include "cryptonote_core.h"
#include "ringct/rctSigs.h"
#include "common/perf_timer.h"
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index e2da535cd..00b40d0ad 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -51,7 +51,7 @@
#include "cryptonote_tx_utils.h"
#include "cryptonote_basic/verification_context.h"
#include "crypto/hash.h"
-#include "cryptonote_basic/checkpoints.h"
+#include "checkpoints/checkpoints.h"
#include "cryptonote_basic/hardfork.h"
#include "blockchain_db/blockchain_db.h"
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 7c6dc7153..2de084d7e 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -45,7 +45,7 @@ using namespace epee;
#include "misc_language.h"
#include <csignal>
#include <p2p/net_node.h>
-#include "cryptonote_basic/checkpoints.h"
+#include "checkpoints/checkpoints.h"
#include "ringct/rctTypes.h"
#include "blockchain_db/blockchain_db.h"
#include "ringct/rctSigs.h"
diff --git a/src/cryptonote_protocol/block_queue.cpp b/src/cryptonote_protocol/block_queue.cpp
index 02a8e3ec2..64dd1fb50 100644
--- a/src/cryptonote_protocol/block_queue.cpp
+++ b/src/cryptonote_protocol/block_queue.cpp
@@ -340,7 +340,7 @@ size_t block_queue::get_num_filled_spans() const
crypto::hash block_queue::get_last_known_hash(const boost::uuids::uuid &connection_id) const
{
boost::unique_lock<boost::recursive_mutex> lock(mutex);
- crypto::hash hash = cryptonote::null_hash;
+ crypto::hash hash = crypto::null_hash;
uint64_t highest_height = 0;
for (const auto &span: blocks)
{
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 22cfb2299..58e5fc380 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -1484,7 +1484,7 @@ skip:
if (!start_from_current_chain)
{
// we'll want to start off from where we are on that peer, which may not be added yet
- if (context.m_last_known_hash != cryptonote::null_hash && r.block_ids.front() != context.m_last_known_hash)
+ if (context.m_last_known_hash != crypto::null_hash && r.block_ids.front() != context.m_last_known_hash)
r.block_ids.push_front(context.m_last_known_hash);
}