aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorrfree2monero <rfreemonero@op.pl>2015-02-20 22:28:03 +0100
committerrfree2monero <rfreemonero@op.pl>2015-02-20 22:28:03 +0100
commitae2a50659f7dc74a5446a0dc3a5f8f78563b9e1f (patch)
tree0d1e7332174fdad966a3048b6b12daee4d07f367 /src/cryptonote_core
parentfixed size_t on windows (diff)
downloadmonero-ae2a50659f7dc74a5446a0dc3a5f8f78563b9e1f.tar.xz
2014 network limit 1.2 +utils +toc -doc -drmonero
new update of the pr with network limits more debug options: discarding downloaded blocks all or after given height. trying to trigger the locking errors. debug levels polished/tuned to sane values. debug/logging improved. warning: this pr should be correct code, but it could make an existing (in master version) locking error appear more often. it's a race on the list (map) of peers, e.g. between closing/deleting them versus working on them in net-limit sleep in sending chunk. the bug is not in this code/this pr, but in the master version. the locking problem of master will be fixed in other pr. problem is ub, and in practice is seems to usually cause program abort (tested on debian stable with updated gcc). see --help for option to add sleep to trigger the error faster.
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain_storage.cpp19
-rw-r--r--src/cryptonote_core/blockchain_storage.h1
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp24
-rw-r--r--src/cryptonote_core/cryptonote_core.h10
4 files changed, 28 insertions, 26 deletions
diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp
index fe80d75ac..4e669daa5 100644
--- a/src/cryptonote_core/blockchain_storage.cpp
+++ b/src/cryptonote_core/blockchain_storage.cpp
@@ -50,6 +50,7 @@
#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;
@@ -178,22 +179,6 @@ bool blockchain_storage::store_genesis_block(bool testnet) {
return true;
}
//------------------------------------------------------------------
-void blockchain_storage::logger_handle(long int ms)
-{
- std::ofstream log_file;
- log_file.open("log/dr-monero/blockchain_log.data", std::ofstream::out | std::ofstream::app);
- log_file.precision(7);
-
- using namespace boost::chrono;
- auto point = steady_clock::now();
- auto time_from_epoh = point.time_since_epoch();
- auto m_ms = duration_cast< milliseconds >( time_from_epoh ).count();
- double ms_f = m_ms;
- ms_f /= 1000.;
-
- log_file << ms_f << " " << ms << std::endl;
-}
-//------------------------------------------------------------------
bool blockchain_storage::store_blockchain()
{
m_is_blockchain_storing = true;
@@ -1776,7 +1761,7 @@ 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");
- logger_handle(block_processing_time);
+ 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)
diff --git a/src/cryptonote_core/blockchain_storage.h b/src/cryptonote_core/blockchain_storage.h
index 6456689b9..38bdfbce7 100644
--- a/src/cryptonote_core/blockchain_storage.h
+++ b/src/cryptonote_core/blockchain_storage.h
@@ -249,7 +249,6 @@ namespace cryptonote
bool complete_timestamps_vector(uint64_t start_height, std::vector<uint64_t>& timestamps);
bool update_next_comulative_size_limit();
bool store_genesis_block(bool testnet);
- void logger_handle(long int ms);
};
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index c8daa3510..49ce63065 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -206,14 +206,30 @@ namespace cryptonote
return m_fast_exit;
}
//-----------------------------------------------------------------------------------------------
- void core::no_check_blocks()
+ void core::test_drop_download()
{
- m_check_blocks = false;
+ m_test_drop_download = false;
}
//-----------------------------------------------------------------------------------------------
- bool core::get_check_blocks()
+ void core::test_drop_download_height(uint64_t height)
{
- return m_check_blocks;
+ 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)
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 9218aef0f..795a6d214 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -77,8 +77,10 @@ namespace cryptonote
bool deinit();
static void set_fast_exit();
static bool get_fast_exit();
- void no_check_blocks();
- bool get_check_blocks();
+ 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);
@@ -151,8 +153,8 @@ namespace cryptonote
bool check_tx_inputs_keyimages_diff(const transaction& tx);
void graceful_exit();
static std::atomic<bool> m_fast_exit;
- bool m_check_blocks = true;
-
+ bool m_test_drop_download = true;
+ uint64_t m_test_drop_download_height = 0;
tx_memory_pool m_mempool;
blockchain_storage m_blockchain_storage;