aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp22
-rw-r--r--src/cryptonote_core/blockchain.h2
-rw-r--r--src/cryptonote_core/blockchain_storage.cpp19
-rw-r--r--src/cryptonote_core/blockchain_storage.h1
-rw-r--r--src/cryptonote_core/hardfork.cpp2
-rw-r--r--src/cryptonote_core/tx_pool.h7
6 files changed, 47 insertions, 6 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index edcdd0a2c..02f592b61 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -100,7 +100,7 @@ static const uint64_t testnet_hard_fork_version_1_till = 624633;
//------------------------------------------------------------------
Blockchain::Blockchain(tx_memory_pool& tx_pool) :
m_db(), m_tx_pool(tx_pool), m_timestamps_and_difficulties_height(0), m_current_block_cumul_sz_limit(0), m_is_in_checkpoint_zone(false),
- m_is_blockchain_storing(false), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_blocks_per_sync(1), m_db_sync_mode(db_async), m_fast_sync(true)
+ m_is_blockchain_storing(false), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_blocks_per_sync(1), m_db_sync_mode(db_async), m_fast_sync(true), m_sync_counter(0)
{
LOG_PRINT_L3("Blockchain::" << __func__);
}
@@ -2145,7 +2145,6 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
// make sure that output being spent matches up correctly with the
// signature spending it.
- TIME_MEASURE_START(aa);
if (!check_tx_input(in_to_key, tx_prefix_hash, tx.signatures[sig_index], pubkeys[sig_index], pmax_used_block_height))
{
it->second[in_to_key.k_image] = false;
@@ -2387,6 +2386,25 @@ void Blockchain::return_tx_to_pool(const std::vector<transaction> &txs)
}
}
//------------------------------------------------------------------
+bool Blockchain::flush_txes_from_pool(const std::list<crypto::hash> &txids)
+{
+ bool res = true;
+ for (const auto &txid: txids)
+ {
+ cryptonote::transaction tx;
+ size_t blob_size;
+ uint64_t fee;
+ bool relayed;
+ LOG_PRINT_L1("Removing txid " << txid << " from the pool");
+ if(!m_tx_pool.take_tx(txid, tx, blob_size, fee, relayed))
+ {
+ LOG_PRINT_L0("Failed to remove txid " << txid << " from the pool");
+ res = false;
+ }
+ }
+ return res;
+}
+//------------------------------------------------------------------
// Needs to validate the block and acquire each transaction from the
// transaction mem_pool, then pass the block and transactions to
// m_db->add_block()
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 87c8a2454..ecabf5376 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -164,6 +164,8 @@ namespace cryptonote
bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const;
+ bool flush_txes_from_pool(const std::list<crypto::hash> &txids);
+
bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const;
bool for_all_blocks(std::function<bool(uint64_t, const crypto::hash&, const block&)>) const;
bool for_all_transactions(std::function<bool(const crypto::hash&, const cryptonote::transaction&)>) const;
diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp
index f656f938b..e1b89f887 100644
--- a/src/cryptonote_core/blockchain_storage.cpp
+++ b/src/cryptonote_core/blockchain_storage.cpp
@@ -1892,6 +1892,25 @@ void blockchain_storage::set_enforce_dns_checkpoints(bool enforce_checkpoints)
m_enforce_dns_checkpoints = enforce_checkpoints;
}
//------------------------------------------------------------------
+bool blockchain_storage::flush_txes_from_pool(const std::list<crypto::hash> &txids)
+{
+ bool res = true;
+ for (const auto &txid: txids)
+ {
+ cryptonote::transaction tx;
+ size_t blob_size;
+ uint64_t fee;
+ bool relayed;
+ LOG_PRINT_L1("Removing txid " << txid << " from the pool");
+ if(!m_tx_pool->take_tx(txid, tx, blob_size, fee, relayed))
+ {
+ LOG_PRINT_L0("Failed to remove txid " << txid << " from the pool");
+ res = false;
+ }
+ }
+ return res;
+}
+//------------------------------------------------------------------
bool blockchain_storage::for_all_key_images(std::function<bool(const crypto::key_image&)> f) const
{
for (key_images_container::const_iterator i = m_spent_keys.begin(); i != m_spent_keys.end(); ++i) {
diff --git a/src/cryptonote_core/blockchain_storage.h b/src/cryptonote_core/blockchain_storage.h
index cb5e17cdb..878202cf1 100644
--- a/src/cryptonote_core/blockchain_storage.h
+++ b/src/cryptonote_core/blockchain_storage.h
@@ -130,6 +130,7 @@ namespace cryptonote
bool is_storing_blockchain()const{return m_is_blockchain_storing;}
uint64_t block_difficulty(size_t i) const;
double get_avg_block_size( size_t count) const;
+ bool flush_txes_from_pool(const std::list<crypto::hash> &txids);
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) const
diff --git a/src/cryptonote_core/hardfork.cpp b/src/cryptonote_core/hardfork.cpp
index 463d9c065..66fb05010 100644
--- a/src/cryptonote_core/hardfork.cpp
+++ b/src/cryptonote_core/hardfork.cpp
@@ -373,7 +373,7 @@ bool HardFork::get_voting_info(uint8_t version, uint32_t &window, uint32_t &vote
votes = 0;
for (size_t n = version; n < 256; ++n)
votes += last_versions[n];
- threshold = (window * heights[current_version].threshold + 99) / 100;
+ threshold = (window * heights[current_fork_index].threshold + 99) / 100;
//assert((votes >= threshold) == enabled);
earliest_height = get_earliest_ideal_height_for_version(version);
voting = heights.back().version;
diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h
index 34dc1f72f..71febcab6 100644
--- a/src/cryptonote_core/tx_pool.h
+++ b/src/cryptonote_core/tx_pool.h
@@ -110,7 +110,7 @@ namespace cryptonote
/*bool flush_pool(const std::strig& folder);
bool inflate_pool(const std::strig& folder);*/
-#define CURRENT_MEMPOOL_ARCHIVE_VER 10
+#define CURRENT_MEMPOOL_ARCHIVE_VER 11
template<class archive_t>
void serialize(archive_t & a, const unsigned int version)
@@ -239,10 +239,11 @@ namespace boost
ar & td.last_failed_height;
ar & td.last_failed_id;
ar & td.receive_time;
- if (version < 9)
- return;
ar & td.last_relayed_time;
ar & td.relayed;
+ if (version < 11)
+ return;
+ ar & td.kept_by_block;
}
}
}