aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp4
-rw-r--r--src/cryptonote_core/blockchain.cpp31
-rw-r--r--src/cryptonote_core/blockchain.h7
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp16
-rw-r--r--src/rpc/core_rpc_server.cpp6
-rw-r--r--src/wallet/wallet2.cpp4
6 files changed, 49 insertions, 19 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index b6978bdc4..c6e24ef98 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -2420,8 +2420,8 @@ bool BlockchainLMDB::for_blocks_range(const uint64_t& h1, const uint64_t& h2, st
MDB_cursor_op op;
if (h1)
{
- MDB_val_set(k, h1);
- op = MDB_SET;
+ k = MDB_val{sizeof(h1), (void*)&h1};
+ op = MDB_SET;
} else
{
op = MDB_FIRST;
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 69d2edf65..8d820cb7e 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2242,6 +2242,24 @@ bool Blockchain::get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<u
return true;
}
//------------------------------------------------------------------
+void Blockchain::on_new_tx_from_block(const cryptonote::transaction &tx)
+{
+#if defined(PER_BLOCK_CHECKPOINT)
+ // check if we're doing per-block checkpointing
+ if (m_db->height() < m_blocks_hash_check.size())
+ {
+ TIME_MEASURE_START(a);
+ m_blocks_txs_check.push_back(get_transaction_hash(tx));
+ TIME_MEASURE_FINISH(a);
+ if(m_show_time_stats)
+ {
+ size_t ring_size = tx.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(tx.vin[0]).key_offsets.size() : 0;
+ MINFO("HASH: " << "-" << " I/M/O: " << tx.vin.size() << "/" << ring_size << "/" << tx.vout.size() << " H: " << 0 << " chcktx: " << a);
+ }
+ }
+#endif
+}
+//------------------------------------------------------------------
//FIXME: it seems this function is meant to be merely a wrapper around
// another function of the same name, this one adding one bit of
// functionality. Should probably move anything more than that
@@ -2257,19 +2275,10 @@ bool Blockchain::check_tx_inputs(transaction& tx, uint64_t& max_used_block_heigh
#if defined(PER_BLOCK_CHECKPOINT)
// check if we're doing per-block checkpointing
- // FIXME: investigate why this block returns
if (m_db->height() < m_blocks_hash_check.size() && kept_by_block)
{
- TIME_MEASURE_START(a);
- m_blocks_txs_check.push_back(get_transaction_hash(tx));
max_used_block_id = null_hash;
max_used_block_height = 0;
- TIME_MEASURE_FINISH(a);
- if(m_show_time_stats)
- {
- size_t ring_size = tx.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(tx.vin[0]).key_offsets.size() : 0;
- MINFO("HASH: " << "-" << " I/M/O: " << tx.vin.size() << "/" << ring_size << "/" << tx.vout.size() << " H: " << 0 << " chcktx: " << a);
- }
return true;
}
#endif
@@ -3249,7 +3258,7 @@ leave:
// XXX old code adds miner tx here
- int tx_index = 0;
+ size_t tx_index = 0;
// Iterate over the block's transaction hashes, grabbing each
// from the tx_pool and validating them. Each is then added
// to txs. Keys spent in each are added to <keys> by the double spend check.
@@ -3331,7 +3340,7 @@ leave:
{
// ND: if fast_check is enabled for blocks, there is no need to check
// the transaction inputs, but do some sanity checks anyway.
- if (memcmp(&m_blocks_txs_check[tx_index++], &tx_id, sizeof(tx_id)) != 0)
+ if (tx_index >= m_blocks_txs_check.size() || memcmp(&m_blocks_txs_check[tx_index++], &tx_id, sizeof(tx_id)) != 0)
{
MERROR_VER("Block with id: " << id << " has at least one transaction (id: " << tx_id << ") with wrong inputs.");
//TODO: why is this done? make sure that keeping invalid blocks makes sense.
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index b8ea657b4..f2bc2ffad 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -898,6 +898,13 @@ namespace cryptonote
void cancel();
+ /**
+ * @brief called when we see a tx originating from a block
+ *
+ * Used for handling txes from historical blocks in a fast way
+ */
+ void on_new_tx_from_block(const cryptonote::transaction &tx);
+
private:
// TODO: evaluate whether or not each of these typedefs are left over from blockchain_storage
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index c7863b816..cf4978acd 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -896,6 +896,9 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------
bool core::add_new_tx(transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
{
+ if (keeped_by_block)
+ get_blockchain_storage().on_new_tx_from_block(tx);
+
if(m_mempool.have_tx(tx_hash))
{
LOG_PRINT_L2("tx " << tx_hash << "already have transaction in tx_pool");
@@ -1023,7 +1026,15 @@ namespace cryptonote
block_verification_context bvc = boost::value_initialized<block_verification_context>();
m_miner.pause();
std::list<block_complete_entry> blocks;
- blocks.push_back(get_block_complete_entry(b, m_mempool));
+ try
+ {
+ blocks.push_back(get_block_complete_entry(b, m_mempool));
+ }
+ catch (const std::exception &e)
+ {
+ m_miner.resume();
+ return false;
+ }
prepare_handle_incoming_blocks(blocks);
m_blockchain_storage.add_new_block(b, bvc);
cleanup_handle_incoming_blocks(true);
@@ -1291,11 +1302,12 @@ namespace cryptonote
bool core::check_updates()
{
static const char software[] = "monero";
- static const char subdir[] = "cli"; // because it can never be simple
#ifdef BUILD_TAG
static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
+ static const char subdir[] = "cli"; // because it can never be simple
#else
static const char buildtag[] = "source";
+ static const char subdir[] = "source"; // because it can never be simple
#endif
if (check_updates_level == UPDATES_DISABLED)
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index a6a61705b..31b6638b2 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -1560,8 +1560,10 @@ namespace cryptonote
static const char software[] = "monero";
#ifdef BUILD_TAG
static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
+ static const char subdir[] = "cli";
#else
static const char buildtag[] = "source";
+ static const char subdir[] = "source";
#endif
if (req.command != "check" && req.command != "download" && req.command != "update")
@@ -1584,8 +1586,8 @@ namespace cryptonote
}
res.update = true;
res.version = version;
- res.user_uri = tools::get_update_url(software, "cli", buildtag, version, true);
- res.auto_uri = tools::get_update_url(software, "cli", buildtag, version, false);
+ res.user_uri = tools::get_update_url(software, subdir, buildtag, version, true);
+ res.auto_uri = tools::get_update_url(software, subdir, buildtag, version, false);
res.hash = hash;
if (req.command == "check")
{
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 6c34c3fd4..83d9d5798 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -2255,7 +2255,7 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const std::stri
// Set blockchain height calculated from current date/time
uint64_t approx_blockchain_height = get_approximate_blockchain_height();
if(approx_blockchain_height > 0) {
- m_refresh_from_block_height = approx_blockchain_height - blocks_per_month;
+ m_refresh_from_block_height = approx_blockchain_height >= blocks_per_month ? approx_blockchain_height - blocks_per_month : 0;
}
}
bool r = store_keys(m_keys_file, password, false);
@@ -4179,7 +4179,7 @@ static size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs)
size += (2*64*32+32+64*32) * n_outputs;
// MGs
- size += n_inputs * (32 * (mixin+1) + 32);
+ size += n_inputs * (64 * (mixin+1) + 32);
// mixRing - not serialized, can be reconstructed
/* size += 2 * 32 * (mixin+1) * n_inputs; */