aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
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_core
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_core')
-rw-r--r--src/cryptonote_core/CMakeLists.txt1
-rw-r--r--src/cryptonote_core/blockchain_storage.cpp29
-rw-r--r--src/cryptonote_core/blockchain_storage.h1
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp52
-rw-r--r--src/cryptonote_core/cryptonote_core.h10
5 files changed, 89 insertions, 4 deletions
diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt
index 3abf93f3c..9eed11874 100644
--- a/src/cryptonote_core/CMakeLists.txt
+++ b/src/cryptonote_core/CMakeLists.txt
@@ -70,6 +70,7 @@ target_link_libraries(cryptonote_core
LINK_PUBLIC
common
crypto
+ otshell_utils
${Boost_DATE_TIME_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp
index 232a7c426..136d4f1d1 100644
--- a/src/cryptonote_core/blockchain_storage.cpp
+++ b/src/cryptonote_core/blockchain_storage.cpp
@@ -49,6 +49,8 @@
#include "crypto/hash.h"
#include "cryptonote_core/checkpoints_create.h"
//#include "serialization/json_archive.h"
+#include "../../contrib/otshell_utils/utils.hpp"
+#include "../../src/p2p/data_logger.hpp"
using namespace cryptonote;
@@ -1154,6 +1156,31 @@ uint64_t blockchain_storage::block_difficulty(size_t i)
return m_blocks[i].cumulative_difficulty - m_blocks[i-1].cumulative_difficulty;
}
//------------------------------------------------------------------
+double blockchain_storage::get_avg_block_size( size_t count)
+{
+ if (count > get_current_blockchain_height()) return 500;
+
+ double average = 0;
+ _dbg1_c("net/blksize", "HEIGHT: " << get_current_blockchain_height());
+ _dbg1_c("net/blksize", "BLOCK ID BY HEIGHT: " << get_block_id_by_height(get_current_blockchain_height()) );
+ _dbg1_c("net/blksize", "BLOCK TAIL ID: " << get_tail_id() );
+ std::vector<size_t> size_vector;
+
+ get_backward_blocks_sizes(get_current_blockchain_height() - count, size_vector, count);
+
+ std::vector<size_t>::iterator it;
+ it = size_vector.begin();
+ while (it != size_vector.end()) {
+ average += *it;
+ _dbg2_c("net/blksize", "VECTOR ELEMENT: " << (*it) );
+ it++;
+ }
+ average = average / count;
+ _dbg1_c("net/blksize", "VECTOR SIZE: " << size_vector.size() << " average=" << average);
+
+ return average;
+}
+//------------------------------------------------------------------
void blockchain_storage::print_blockchain(uint64_t start_index, uint64_t end_index)
{
std::stringstream ss;
@@ -1745,6 +1772,8 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
<< "), coinbase_blob_size: " << coinbase_blob_size << ", cumulative size: " << cumulative_block_size
<< ", " << block_processing_time << "("<< target_calculating_time << "/" << longhash_calculating_time << ")ms");
+ epee::net_utils::data_logger::get_instance().add_data("blockchain_processing_time", block_processing_time);
+
bvc.m_added_to_main_chain = true;
/*if(!m_orphanes_reorganize_in_work)
review_orphaned_blocks_with_new_block_id(id, true);*/
diff --git a/src/cryptonote_core/blockchain_storage.h b/src/cryptonote_core/blockchain_storage.h
index a74d492d7..505ed4574 100644
--- a/src/cryptonote_core/blockchain_storage.h
+++ b/src/cryptonote_core/blockchain_storage.h
@@ -134,6 +134,7 @@ namespace cryptonote
uint64_t get_current_comulative_blocksize_limit();
bool is_storing_blockchain(){return m_is_blockchain_storing;}
uint64_t block_difficulty(size_t i);
+ double get_avg_block_size( size_t count);
template<class t_ids_container, class t_blocks_container, class t_missed_container>
bool get_blocks(const t_ids_container& block_ids, t_blocks_container& blocks, t_missed_container& missed_bs)
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 11127290e..9be5eca9b 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -145,6 +145,11 @@ namespace cryptonote
set_enforce_dns_checkpoints(command_line::get_arg(vm, daemon_args::arg_dns_checkpoints));
+ test_drop_download_height(command_line::get_arg(vm, command_line::arg_test_drop_download_height));
+
+ if (command_line::get_arg(vm, command_line::arg_test_drop_download) == true)
+ test_drop_download();
+
return true;
}
//-----------------------------------------------------------------------------------------------
@@ -216,12 +221,51 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------
bool core::deinit()
{
- m_miner.stop();
- m_mempool.deinit();
- m_blockchain_storage.deinit();
+ m_miner.stop();
+ m_mempool.deinit();
+ if (!m_fast_exit)
+ {
+ m_blockchain_storage.deinit();
+ }
return true;
}
//-----------------------------------------------------------------------------------------------
+ void core::set_fast_exit()
+ {
+ m_fast_exit = true;
+ }
+ //-----------------------------------------------------------------------------------------------
+ bool core::get_fast_exit()
+ {
+ return m_fast_exit;
+ }
+ //-----------------------------------------------------------------------------------------------
+ void core::test_drop_download()
+ {
+ m_test_drop_download = false;
+ }
+ //-----------------------------------------------------------------------------------------------
+ void core::test_drop_download_height(uint64_t height)
+ {
+ m_test_drop_download_height = height;
+ }
+ //-----------------------------------------------------------------------------------------------
+ bool core::get_test_drop_download()
+ {
+ return m_test_drop_download;
+ }
+ //-----------------------------------------------------------------------------------------------
+ bool core::get_test_drop_download_height()
+ {
+ if (m_test_drop_download_height == 0)
+ return true;
+
+ if (get_blockchain_storage().get_current_blockchain_height() <= m_test_drop_download_height)
+ return true;
+
+ return false;
+ }
+ //-----------------------------------------------------------------------------------------------
bool core::handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, bool keeped_by_block)
{
tvc = boost::value_initialized<tx_verification_context>();
@@ -624,4 +668,6 @@ namespace cryptonote
{
raise(SIGTERM);
}
+
+ std::atomic<bool> core::m_fast_exit(false);
}
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 1921ef14d..bb53ecb81 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -75,6 +75,12 @@ namespace cryptonote
bool init(const boost::program_options::variables_map& vm);
bool set_genesis_block(const block& b);
bool deinit();
+ static void set_fast_exit();
+ static bool get_fast_exit();
+ void test_drop_download();
+ void test_drop_download_height(uint64_t height);
+ bool get_test_drop_download();
+ bool get_test_drop_download_height();
uint64_t get_current_blockchain_height();
bool get_blockchain_top(uint64_t& heeight, crypto::hash& top_id);
bool get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks, std::list<transaction>& txs);
@@ -148,7 +154,9 @@ namespace cryptonote
bool on_update_blocktemplate_interval();
bool check_tx_inputs_keyimages_diff(const transaction& tx);
void graceful_exit();
-
+ static std::atomic<bool> m_fast_exit;
+ bool m_test_drop_download = true;
+ uint64_t m_test_drop_download_height = 0;
tx_memory_pool m_mempool;
blockchain_storage m_blockchain_storage;