diff options
| author | Riccardo Spagni <ric@spagni.net> | 2015-04-02 17:43:38 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2015-04-02 17:43:43 +0200 |
| commit | 6f0d93097e3fbe9b1101e90ad1adc718a18263aa (patch) | |
| tree | b5a2189ee6cbdd6f8ba57cd1d46edac7ac599ee3 /src/cryptonote_core/blockchain_storage.cpp | |
| parent | ea32a84e45763f70d3f8dc4d831baeee58c1185a (diff) | |
| parent | 618f20ce494ada0ac6ab087b33fc45e4968b3ac8 (diff) | |
| download | monzero-core-6f0d93097e3fbe9b1101e90ad1adc718a18263aa.tar.gz monzero-core-6f0d93097e3fbe9b1101e90ad1adc718a18263aa.tar.xz monzero-core-6f0d93097e3fbe9b1101e90ad1adc718a18263aa.zip | |
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/blockchain_storage.cpp')
| -rw-r--r-- | src/cryptonote_core/blockchain_storage.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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);*/ |
