aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_protocol/cryptonote_protocol_handler.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-04-02 17:43:38 +0200
committerRiccardo Spagni <ric@spagni.net>2015-04-02 17:43:43 +0200
commit6f0d93097e3fbe9b1101e90ad1adc718a18263aa (patch)
treeb5a2189ee6cbdd6f8ba57cd1d46edac7ac599ee3 /src/cryptonote_protocol/cryptonote_protocol_handler.h
parentMerge pull request #251 (diff)
parentNetwork 1.7; Quieted the debug a bit. (diff)
downloadmonero-6f0d93097e3fbe9b1101e90ad1adc718a18263aa.tar.xz
Merge pull request #252
618f20c Network 1.7; Quieted the debug a bit. (rfree2monero) 391c7f9 Utils: use const, document dbg. Less default debug (rfree2monero) 44f4234 [fix] mac os x includes std::random... (rfree2monero) 162c993 Network 1.6: network limits, logging, +doxy (rfree2monero) a3b2226 my changelog (rfree2monero) 2900b1e doxygen files (rfree2monero) 1489310 doxygen related tool (rfree2monero) f9dba47 added windows_stream.* console colors (rfree2monero) c511abf remerged; commands JSON. logging upgrade. doxygen (rfree2monero) f79821a fix locking in count-peers thread (2) (rfree2monero) 0198ffb 2014 network limit 1.3 fix log/path/data +utils (rfree2monero) ae2a506 2014 network limit 1.2 +utils +toc -doc -drmonero (rfree2monero) 0f06dca fixed size_t on windows (rfree2monero) 39fc63f removed not needed <netinet/in.h> (rfree2monero) 5ce4256 2014 network limit 1.1 +utils +toc -doc -drmonero (rfree2monero) eabb519 2014 network limit 1.0a +utils +toc -doc -drmonero (rfree2monero)
Diffstat (limited to 'src/cryptonote_protocol/cryptonote_protocol_handler.h')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.h39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h
index a3b79856e..571c36dc1 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.h
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h
@@ -1,3 +1,7 @@
+/// @file
+/// @author rfree (current maintainer/user in monero.cc project - most of code is from CryptoNote)
+/// @brief This is the orginal cryptonote protocol network-events handler, modified by us
+
// Copyright (c) 2014-2015, The Monero Project
//
// All rights reserved.
@@ -41,15 +45,36 @@
#include "cryptonote_core/connection_context.h"
#include "cryptonote_core/cryptonote_stat_info.h"
#include "cryptonote_core/verification_context.h"
+// #include <netinet/in.h>
+#include <boost/circular_buffer.hpp>
PUSH_WARNINGS
DISABLE_VS_WARNINGS(4355)
+#define LOCALHOST_INT 2130706433
+
namespace cryptonote
{
+ class cryptonote_protocol_handler_base_pimpl;
+ class cryptonote_protocol_handler_base {
+ private:
+ std::unique_ptr<cryptonote_protocol_handler_base_pimpl> mI;
+
+ public:
+ cryptonote_protocol_handler_base();
+ virtual ~cryptonote_protocol_handler_base();
+ void handler_request_blocks_history(std::list<crypto::hash>& ids); // before asking for list of objects, we can change the list still
+ void handler_response_blocks_now(size_t packet_size);
+
+ virtual double get_avg_block_size() = 0;
+ virtual double estimate_one_block_size() noexcept; // for estimating size of blocks to download
+
+ virtual std::ofstream& get_logreq() const =0;
+ };
+
template<class t_core>
- class t_cryptonote_protocol_handler: public i_cryptonote_protocol
+ class t_cryptonote_protocol_handler: public i_cryptonote_protocol, cryptonote_protocol_handler_base
{
public:
typedef cryptonote_connection_context connection_context;
@@ -106,6 +131,12 @@ namespace cryptonote
nodetool::i_p2p_endpoint<connection_context>* m_p2p;
std::atomic<uint32_t> m_syncronized_connections_count;
std::atomic<bool> m_synchronized;
+ bool m_one_request = true;
+
+ // static std::ofstream m_logreq;
+ std::mutex m_buffer_mutex;
+ double get_avg_block_size();
+ boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10);
template<class t_parametr>
bool post_notify(typename t_parametr::request& arg, cryptonote_connection_context& context)
@@ -113,6 +144,7 @@ namespace cryptonote
LOG_PRINT_L2("[" << epee::net_utils::print_connection_context_short(context) << "] post " << typeid(t_parametr).name() << " -->");
std::string blob;
epee::serialization::store_t_to_binary(arg, blob);
+ //handler_response_blocks_now(blob.size()); // XXX
return m_p2p->invoke_notify_to_peer(t_parametr::ID, blob, context);
}
@@ -124,8 +156,11 @@ namespace cryptonote
epee::serialization::store_t_to_binary(arg, arg_buff);
return m_p2p->relay_notify_to_all(t_parametr::ID, arg_buff, exlude_context);
}
+
+ virtual std::ofstream& get_logreq() const ;
};
-}
+
+} // namespace
#include "cryptonote_protocol_handler.inl"