9079a32 Fix typo (warptangent)
3796941 blockchain.cpp: Change indentation from 4 to 2 spaces (warptangent)
725acc7 Replace tabs with two spaces for consistency with rest of codebase (warptangent)
message(STATUS"Found BerkeleyDB includes, but could not find BerkeleyDB library. Please make sure you have installed libdb and libdb-dev or the equivalent")
message(STATUS"Found BerkeleyDB includes, but could not find BerkeleyDB library. Please make sure you have installed libdb and libdb-dev or the equivalent")
lmdb_db_open(txn,LMDB_OUTPUT_TXS,MDB_INTEGERKEY|MDB_CREATE,m_output_txs,"Failed to open db handle for m_output_txs");
lmdb_db_open(txn,LMDB_OUTPUT_TXS,MDB_INTEGERKEY|MDB_CREATE,m_output_txs,"Failed to open db handle for m_output_txs");
lmdb_db_open(txn,LMDB_OUTPUT_INDICES,MDB_INTEGERKEY|MDB_CREATE,m_output_indices,"Failed to open db handle for m_output_indices");
lmdb_db_open(txn,LMDB_OUTPUT_INDICES,MDB_INTEGERKEY|MDB_CREATE,m_output_indices,"Failed to open db handle for m_output_indices");
lmdb_db_open(txn,LMDB_OUTPUT_AMOUNTS,MDB_INTEGERKEY|MDB_DUPSORT|MDB_DUPFIXED|MDB_CREATE,m_output_amounts,"Failed to open db handle for m_output_amounts");
lmdb_db_open(txn,LMDB_OUTPUT_AMOUNTS,MDB_INTEGERKEY|MDB_DUPSORT|MDB_DUPFIXED|MDB_CREATE,m_output_amounts,"Failed to open db handle for m_output_amounts");
lmdb_db_open(txn,LMDB_OUTPUT_KEYS,MDB_INTEGERKEY|MDB_CREATE,m_output_keys,"Failed to open db handle for m_output_keys");
lmdb_db_open(txn,LMDB_OUTPUT_KEYS,MDB_INTEGERKEY|MDB_CREATE,m_output_keys,"Failed to open db handle for m_output_keys");
lmdb_db_open(txn,LMDB_SPENT_KEYS,MDB_CREATE,m_spent_keys,"Failed to open db handle for m_spent_keys");
lmdb_db_open(txn,LMDB_SPENT_KEYS,MDB_CREATE,m_spent_keys,"Failed to open db handle for m_spent_keys");
CHECK_AND_ASSERT_MES(m_checkpoints.is_alternative_block_allowed(m_blocks.size()-1,alt_block.second.height),false,"stored alternative block not allowed, blockchain.bin invalid");
CHECK_AND_ASSERT_MES(m_checkpoints.is_alternative_block_allowed(m_blocks.size()-1,alt_block.second.height),false,"stored alternative block not allowed, blockchain.bin invalid");
@ -1837,13 +1837,13 @@ void blockchain_storage::check_against_checkpoints(const checkpoints& points, bo
// if asked to enforce checkpoints, roll back to a couple of blocks before the checkpoint
// if asked to enforce checkpoints, roll back to a couple of blocks before the checkpoint
if(enforce)
if(enforce)
{
{
LOG_ERROR("Local blockchain failed to pass a checkpoint, rolling back!");
LOG_ERROR("Local blockchain failed to pass a checkpoint, rolling back!");
std::list<block>empty;
std::list<block>empty;
rollback_blockchain_switching(empty,pt.first-2);
rollback_blockchain_switching(empty,pt.first-2);
}
}
else
else
{
{
LOG_ERROR("WARNING: local blockchain failed to pass a MoneroPulse checkpoint, and you could be on a fork. You should either sync up from scratch, OR download a fresh blockchain bootstrap, OR enable checkpoint enforcing with the --enforce-dns-checkpointing command-line option");
LOG_ERROR("WARNING: local blockchain failed to pass a MoneroPulse checkpoint, and you could be on a fork. You should either sync up from scratch, OR download a fresh blockchain bootstrap, OR enable checkpoint enforcing with the --enforce-dns-checkpointing command-line option");
// return m_core.get_blockchain_storage().get_avg_block_size(count); // this does not count too well the actuall network-size of data we need to download
// return m_core.get_blockchain_storage().get_avg_block_size(count); // this does not count too well the actuall network-size of data we need to download
CRITICAL_REGION_LOCAL(m_buffer_mutex);
CRITICAL_REGION_LOCAL(m_buffer_mutex);
double avg = 0;
double avg = 0;
if (m_avg_buffer.size() == 0) {
if (m_avg_buffer.size() == 0) {
_warn("m_avg_buffer.size() == 0");
_warn("m_avg_buffer.size() == 0");
return 500;
return 500;
}
}
const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option
const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option
long int dbg_repeat=0;
long int dbg_repeat=0;
do {
do {
for (auto element : m_avg_buffer) avg += element;
for (auto element : m_avg_buffer) avg += element;
} while(dbg_poke_lock && (dbg_repeat++)<100000); // in debug/poke mode, repeat this calculation to trigger hidden locking error if there is one
} while(dbg_poke_lock && (dbg_repeat++)<100000); // in debug/poke mode, repeat this calculation to trigger hidden locking error if there is one
return avg / m_avg_buffer.size();
return avg / m_avg_buffer.size();
}
}
@ -440,33 +440,33 @@ namespace cryptonote
size_t size = 0;
size_t size = 0;
for (auto element : arg.txs) size += element.size();
for (auto element : arg.txs) size += element.size();
for (auto element : arg.blocks) {
for (auto element : arg.blocks) {
size += element.block.size();
size += element.block.size();
for (auto tx : element.txs)
for (auto tx : element.txs)
size += tx.size();
size += tx.size();
}
}
for (auto element : arg.missed_ids)
for (auto element : arg.missed_ids)
size += sizeof(element.data);
size += sizeof(element.data);
size += sizeof(arg.current_blockchain_height);
size += sizeof(arg.current_blockchain_height);
{
{
CRITICAL_REGION_LOCAL(m_buffer_mutex);
CRITICAL_REGION_LOCAL(m_buffer_mutex);
m_avg_buffer.push_back(size);
m_avg_buffer.push_back(size);
const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option
const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option
long int dbg_repeat=0;
long int dbg_repeat=0;
do {
do {
m_avg_buffer.push_back(666); // a test value
m_avg_buffer.push_back(666); // a test value
m_avg_buffer.erase_end(1);
m_avg_buffer.erase_end(1);
} while(dbg_poke_lock && (dbg_repeat++)<100000); // in debug/poke mode, repeat this calculation to trigger hidden locking error if there is one
} while(dbg_poke_lock && (dbg_repeat++)<100000); // in debug/poke mode, repeat this calculation to trigger hidden locking error if there is one
}
}
/*using namespace boost::chrono;
/*using namespace boost::chrono;
auto point = steady_clock::now();
auto point = steady_clock::now();
auto time_from_epoh = point.time_since_epoch();
auto time_from_epoh = point.time_since_epoch();
auto sec = duration_cast< seconds >( time_from_epoh ).count();*/
auto sec = duration_cast< seconds >( time_from_epoh ).count();*/
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
const command_line::arg_descriptor<bool> arg_no_igd= {"no-igd", "Disable UPnP port mapping"};
const command_line::arg_descriptor<bool> arg_no_igd= {"no-igd", "Disable UPnP port mapping"};
const command_line::arg_descriptor<bool> arg_offline= {"offline", "Do not listen for peers, nor connect to any"};
const command_line::arg_descriptor<bool> arg_offline= {"offline", "Do not listen for peers, nor connect to any"};
const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max limit of out peers", -1};
const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max limit of out peers", -1};
const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1};
const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1};