mirror of
https://github.com/monero-project/monero.git
synced 2025-07-24 06:50:43 -04:00
some fixes
This commit is contained in:
parent
296ae46ed8
commit
8efa1313f3
67 changed files with 1523 additions and 757 deletions
|
@ -104,6 +104,9 @@ bool blockchain_storage::init(const std::string& config_folder)
|
|||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::store_blockchain()
|
||||
{
|
||||
m_is_blockchain_storing = true;
|
||||
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([&](){m_is_blockchain_storing=false;});
|
||||
|
||||
LOG_PRINT_L0("Storing blockchain...");
|
||||
if (!tools::create_directories_if_necessary(m_config_folder))
|
||||
{
|
||||
|
@ -1029,7 +1032,7 @@ void blockchain_storage::print_blockchain(uint64_t start_index, uint64_t end_ind
|
|||
|
||||
for(size_t i = start_index; i != m_blocks.size() && i != end_index; i++)
|
||||
{
|
||||
ss << "height " << i << ", timastamp " << m_blocks[i].bl.timestamp << ", cumul_dif " << m_blocks[i].cumulative_difficulty << ", cumul_size " << m_blocks[i].block_cumulative_size
|
||||
ss << "height " << i << ", timestamp " << m_blocks[i].bl.timestamp << ", cumul_dif " << m_blocks[i].cumulative_difficulty << ", cumul_size " << m_blocks[i].block_cumulative_size
|
||||
<< "\nid\t\t" << get_block_hash(m_blocks[i].bl)
|
||||
<< "\ndifficulty\t\t" << block_difficulty(i) << ", nonce " << m_blocks[i].bl.nonce << ", tx_count " << m_blocks[i].bl.tx_hashes.size() << ENDL;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ namespace cryptonote
|
|||
bool check_tx_inputs(const transaction& tx, uint64_t* pmax_used_block_height = NULL);
|
||||
bool check_tx_inputs(const transaction& tx, uint64_t& pmax_used_block_height, crypto::hash& max_used_block_id);
|
||||
uint64_t get_current_comulative_blocksize_limit();
|
||||
bool is_storing_blockchain(){return m_is_blockchain_storing;}
|
||||
|
||||
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)
|
||||
|
@ -188,6 +189,7 @@ namespace cryptonote
|
|||
std::string m_config_folder;
|
||||
checkpoints m_checkpoints;
|
||||
std::atomic<bool> m_is_in_checkpoint_zone;
|
||||
std::atomic<bool> m_is_blockchain_storing;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,32 +6,10 @@
|
|||
#include <unordered_set>
|
||||
#include <atomic>
|
||||
#include "net/net_utils_base.h"
|
||||
|
||||
#include "copyable_atomic.h"
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
class my_atomic: public std::atomic<uint32_t>
|
||||
{
|
||||
public:
|
||||
my_atomic()
|
||||
{};
|
||||
my_atomic(const my_atomic& a):std::atomic<uint32_t>(a.load())
|
||||
{}
|
||||
my_atomic& operator= (const my_atomic& a)
|
||||
{
|
||||
store(a.load());
|
||||
return *this;
|
||||
}
|
||||
uint32_t operator++()
|
||||
{
|
||||
return std::atomic<uint32_t>::operator++();
|
||||
}
|
||||
uint32_t operator++(int fake)
|
||||
{
|
||||
return std::atomic<uint32_t>::operator++(fake);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct cryptonote_connection_context: public epee::net_utils::connection_context_base
|
||||
{
|
||||
|
@ -40,6 +18,7 @@ namespace cryptonote
|
|||
{
|
||||
state_befor_handshake = 0, //default state
|
||||
state_synchronizing,
|
||||
state_idle,
|
||||
state_normal
|
||||
};
|
||||
|
||||
|
@ -48,7 +27,25 @@ namespace cryptonote
|
|||
std::unordered_set<crypto::hash> m_requested_objects;
|
||||
uint64_t m_remote_blockchain_height;
|
||||
uint64_t m_last_response_height;
|
||||
my_atomic m_callback_request_count; //in debug purpose: problem with double callback rise
|
||||
epee::copyable_atomic m_callback_request_count; //in debug purpose: problem with double callback rise
|
||||
//size_t m_score; TODO: add score calculations
|
||||
};
|
||||
|
||||
inline std::string get_protocol_state_string(cryptonote_connection_context::state s)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case cryptonote_connection_context::state_befor_handshake:
|
||||
return "state_befor_handshake";
|
||||
case cryptonote_connection_context::state_synchronizing:
|
||||
return "state_synchronizing";
|
||||
case cryptonote_connection_context::state_idle:
|
||||
return "state_idle";
|
||||
case cryptonote_connection_context::state_normal:
|
||||
return "state_normal";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -109,25 +109,25 @@ namespace cryptonote {
|
|||
uint64_t prefix;
|
||||
if (!tools::base58::decode_addr(str, prefix, data))
|
||||
{
|
||||
LOG_PRINT_L0("Invalid address format");
|
||||
LOG_PRINT_L1("Invalid address format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX != prefix)
|
||||
{
|
||||
LOG_PRINT_L0("Wrong address prefix: " << prefix << ", expected " << CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX);
|
||||
LOG_PRINT_L1("Wrong address prefix: " << prefix << ", expected " << CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!::serialization::parse_binary(data, adr))
|
||||
{
|
||||
LOG_PRINT_L0("Account public address keys can't be parsed");
|
||||
LOG_PRINT_L1("Account public address keys can't be parsed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!crypto::check_key(adr.m_spend_public_key) || !crypto::check_key(adr.m_view_public_key))
|
||||
{
|
||||
LOG_PRINT_L0("Failed to validate address keys");
|
||||
LOG_PRINT_L1("Failed to validate address keys");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ namespace cryptonote {
|
|||
|
||||
if(buff.size()!=sizeof(public_address_outer_blob))
|
||||
{
|
||||
LOG_PRINT_L0("Wrong public address size: " << buff.size() << ", expected size: " << sizeof(public_address_outer_blob));
|
||||
LOG_PRINT_L1("Wrong public address size: " << buff.size() << ", expected size: " << sizeof(public_address_outer_blob));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -149,13 +149,13 @@ namespace cryptonote {
|
|||
|
||||
if(blob.m_ver > CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER)
|
||||
{
|
||||
LOG_PRINT_L0("Unknown version of public address: " << blob.m_ver << ", expected " << CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER);
|
||||
LOG_PRINT_L1("Unknown version of public address: " << blob.m_ver << ", expected " << CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(blob.check_sum != get_account_address_checksum(blob))
|
||||
{
|
||||
LOG_PRINT_L0("Wrong public address checksum");
|
||||
LOG_PRINT_L1("Wrong public address checksum");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -230,9 +230,9 @@ namespace cryptonote
|
|||
return false;
|
||||
}
|
||||
|
||||
boost::uint64_t amount_in = 0;
|
||||
uint64_t amount_in = 0;
|
||||
get_inputs_money_amount(tx, amount_in);
|
||||
boost::uint64_t amount_out = get_outs_money_amount(tx);
|
||||
uint64_t amount_out = get_outs_money_amount(tx);
|
||||
|
||||
if(amount_in <= amount_out)
|
||||
{
|
||||
|
|
|
@ -139,7 +139,6 @@ namespace cryptonote
|
|||
{
|
||||
if (0 == amount)
|
||||
{
|
||||
chunk_handler(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue