aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt9
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.cpp5
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.h2
-rw-r--r--src/blockchain_db/blockchain_db.h3
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp9
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
-rw-r--r--src/cryptonote_core/blockchain.cpp8
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl5
-rw-r--r--src/daemon/command_parser_executor.cpp2
-rw-r--r--src/daemon/command_server.cpp2
-rw-r--r--src/wallet/CMakeLists.txt7
-rw-r--r--src/wallet/wallet2.cpp6
12 files changed, 41 insertions, 19 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 70bb215d0..5a79325ef 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -82,8 +82,13 @@ function (bitmonero_add_library name)
FILES
${ARGN})
- add_library("${name}"
- ${ARGN})
+ # Define a ("virtual") object library and an actual library that links those
+ # objects together. The virtual libraries can be arbitrarily combined to link
+ # any subset of objects into one library archive. This is used for releasing
+ # libwallet, which combines multiple components.
+ set(objlib obj_${name})
+ add_library(${objlib} OBJECT ${ARGN})
+ add_library("${name}" STATIC $<TARGET_OBJECTS:${objlib}>)
set_property(TARGET "${name}"
PROPERTY
FOLDER "libs")
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp
index 4ec284e38..137ed9dc6 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.cpp
+++ b/src/blockchain_db/berkeleydb/db_bdb.cpp
@@ -1235,7 +1235,7 @@ void BlockchainBDB::unlock()
check_open();
}
-bool BlockchainBDB::block_exists(const crypto::hash& h) const
+bool BlockchainBDB::block_exists(const crypto::hash& h, uint64_t *height) const
{
LOG_PRINT_L3("BlockchainBDB::" << __func__);
check_open();
@@ -1251,6 +1251,9 @@ bool BlockchainBDB::block_exists(const crypto::hash& h) const
else if (get_result)
throw0(DB_ERROR("DB error attempting to fetch block index from hash"));
+ if (height)
+ *height = get_result - 1;
+
return true;
}
diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h
index f8e9440bd..f320ab0e3 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.h
+++ b/src/blockchain_db/berkeleydb/db_bdb.h
@@ -250,7 +250,7 @@ public:
virtual void unlock();
- virtual bool block_exists(const crypto::hash& h) const;
+ virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const;
virtual block get_block(const crypto::hash& h) const;
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index d26080a3b..5b6a793d8 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -736,10 +736,11 @@ public:
* @brief checks if a block exists
*
* @param h the hash of the requested block
+ * @param height if non NULL, returns the block's height if found
*
* @return true of the block exists, otherwise false
*/
- virtual bool block_exists(const crypto::hash& h) const = 0;
+ virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const = 0;
/**
* @brief fetches the block with the given hash
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index c0cf28dda..8ad875fc8 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1387,7 +1387,7 @@ void BlockchainLMDB::unlock()
auto_txn.commit(); \
} while(0)
-bool BlockchainLMDB::block_exists(const crypto::hash& h) const
+bool BlockchainLMDB::block_exists(const crypto::hash& h, uint64_t *height) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@@ -1405,7 +1405,14 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h) const
else if (get_result)
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch block index from hash", get_result).c_str()));
else
+ {
+ if (height)
+ {
+ const blk_height *bhp = (const blk_height *)key.mv_data;
+ *height = bhp->bh_height;
+ }
ret = true;
+ }
TXN_POSTFIX_RDONLY();
return ret;
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index 050e9e0ae..9df4b86d1 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -168,7 +168,7 @@ public:
virtual void unlock();
- virtual bool block_exists(const crypto::hash& h) const;
+ virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const;
virtual block get_block(const crypto::hash& h) const;
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 37bd6e810..b15eb4b90 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -1801,12 +1801,8 @@ bool Blockchain::find_blockchain_supplement(const std::list<crypto::hash>& qbloc
{
try
{
- split_height = m_db->get_block_height(*bl_it);
- break;
- }
- catch (const BLOCK_DNE& e)
- {
- continue;
+ if (m_db->block_exists(*bl_it, &split_height))
+ break;
}
catch (const std::exception& e)
{
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 6f095a76f..81d96d5bf 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -277,8 +277,11 @@ namespace cryptonote
m_core.set_target_blockchain_height(static_cast<int64_t>(hshd.current_height));
int64_t diff = static_cast<int64_t>(hshd.current_height) - static_cast<int64_t>(m_core.get_current_blockchain_height());
+ int64_t max_block_height = max(static_cast<int64_t>(hshd.current_height),static_cast<int64_t>(m_core.get_current_blockchain_height()));
+ int64_t last_block_v1 = 1009826;
+ int64_t diff_v2 = max_block_height > last_block_v1 ? min(abs(diff), max_block_height - last_block_v1) : 0;
LOG_PRINT_CCONTEXT_YELLOW("Sync data returned unknown top block: " << m_core.get_current_blockchain_height() << " -> " << hshd.current_height
- << " [" << std::abs(diff) << " blocks (" << diff / (24 * 60 * 60 / DIFFICULTY_TARGET_V1) << " days) "
+ << " [" << std::abs(diff) << " blocks (" << ((abs(diff) - diff_v2) / (24 * 60 * 60 / DIFFICULTY_TARGET_V1)) + (diff_v2 / (24 * 60 * 60 / DIFFICULTY_TARGET_V2)) << " days) "
<< (0 <= diff ? std::string("behind") : std::string("ahead"))
<< "] " << ENDL << "SYNCHRONIZATION started", (is_inital ? LOG_LEVEL_0:LOG_LEVEL_1));
LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id);
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 166fe04ca..00ea6ef6c 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -225,7 +225,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
{
if(!args.size())
{
- std::cout << "Please specify a wallet address to mine for: start_mining <addr> [threads=1]" << std::endl;
+ std::cout << "Please specify a wallet address to mine for: start_mining <addr> [<threads>]" << std::endl;
return true;
}
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index aabc2f09a..ce8ac44fc 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -92,7 +92,7 @@ t_command_server::t_command_server(
m_command_lookup.set_handler(
"start_mining"
, std::bind(&t_command_parser_executor::start_mining, &m_parser, p::_1)
- , "Start mining for specified address, start_mining <addr> [threads=1]"
+ , "Start mining for specified address, start_mining <addr> [<threads>], default 1 thread"
);
m_command_lookup.set_handler(
"stop_mining"
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
index c4585f9ee..48e4b0a23 100644
--- a/src/wallet/CMakeLists.txt
+++ b/src/wallet/CMakeLists.txt
@@ -27,7 +27,6 @@
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# include (${PROJECT_SOURCE_DIR}/cmake/libutils.cmake)
-include (${PROJECT_SOURCE_DIR}/cmake/MergeStaticLibs.cmake)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
@@ -76,7 +75,11 @@ target_link_libraries(wallet
${EXTRA_LIBRARIES})
set(libs_to_merge wallet cryptonote_core mnemonics common crypto)
-merge_static_libs(wallet_merged "${libs_to_merge}")
+
+foreach(lib ${libs_to_merge})
+ list(APPEND objlibs $<TARGET_OBJECTS:obj_${lib}>) # matches naming convention in src/CMakeLists.txtA
+endforeach()
+add_library(wallet_merged STATIC ${objlibs})
install(TARGETS wallet_merged
ARCHIVE DESTINATION lib)
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index d889720af..c6e2411b6 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -2709,6 +2709,8 @@ void wallet2::get_outs(std::vector<std::vector<entry>> &outs, const std::list<tr
}
}
LOG_PRINT_L1("" << num_outs << " outputs of size " << print_money(amount));
+ THROW_WALLET_EXCEPTION_IF(num_outs == 0, error::wallet_internal_error,
+ "histogram reports no outputs for " + boost::lexical_cast<std::string>(amount) + ", not even ours");
if (num_outs <= requested_outputs_count)
{
@@ -3468,7 +3470,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
return ptx_vector;
}
-std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon)
+std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon)
{
std::vector<size_t> unused_transfers_indices;
std::vector<size_t> unused_dust_indices;
@@ -3485,6 +3487,8 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono
uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
const bool use_rct = use_fork_rules(4, 0);
+ fee_multiplier = sanitize_fee_multiplier(fee_multiplier);
+
// gather all our dust and non dust outputs
for (size_t i = 0; i < m_transfers.size(); ++i)
{