aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.h
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-10-08 15:55:03 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-10-08 15:55:03 -0500
commitbf525793c724f62d4716aaca59345ba2e13a2c3c (patch)
treead7ea60c6faf8ca103a686529fc1c716e272a9a5 /src/cryptonote_core/blockchain.h
parentMerge pull request #5960 (diff)
parentmonerod can now sync from pruned blocks (diff)
downloadmonero-bf525793c724f62d4716aaca59345ba2e13a2c3c.tar.xz
Merge pull request #5915
8330e77 monerod can now sync from pruned blocks (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/blockchain.h')
-rw-r--r--src/cryptonote_core/blockchain.h32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 552a53e89..6467031c2 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -393,13 +393,14 @@ namespace cryptonote
*
* @param qblock_ids the foreign chain's "short history" (see get_short_chain_history)
* @param hashes the hashes to be returned, return-by-reference
+ * @param weights the block weights to be returned, return-by-reference
* @param start_height the start height, return-by-reference
* @param current_height the current blockchain height, return-by-reference
* @param clip_pruned whether to constrain results to unpruned data
*
* @return true if a block found in common, else false
*/
- bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, std::vector<crypto::hash>& hashes, uint64_t& start_height, uint64_t& current_height, bool clip_pruned) const;
+ bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, std::vector<crypto::hash>& hashes, std::vector<uint64_t>* weights, uint64_t& start_height, uint64_t& current_height, bool clip_pruned) const;
/**
* @brief get recent block hashes for a foreign chain
@@ -409,11 +410,12 @@ namespace cryptonote
* BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT additional (more recent) hashes.
*
* @param qblock_ids the foreign chain's "short history" (see get_short_chain_history)
+ * @param clip_pruned clip pruned blocks if true, include them otherwise
* @param resp return-by-reference the split height and subsequent blocks' hashes
*
* @return true if a block found in common, else false
*/
- bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
+ bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
/**
* @brief find the most recent common point between ours and a foreign chain
@@ -687,8 +689,8 @@ namespace cryptonote
*
* @return false if an unexpected exception occurs, else true
*/
- template<class t_ids_container, class t_tx_container, class t_missed_container>
- bool get_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs, bool pruned = false) const;
+ bool get_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
+ bool get_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<tx_blob_entry>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
template<class t_ids_container, class t_tx_container, class t_missed_container>
bool get_split_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
template<class t_ids_container, class t_tx_container, class t_missed_container>
@@ -968,9 +970,8 @@ namespace cryptonote
cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid) const;
bool for_all_txpool_txes(std::function<bool(const crypto::hash&, const txpool_tx_meta_t&, const cryptonote::blobdata*)>, bool include_blob = false, bool include_unrelayed_txes = true) const;
- bool is_within_compiled_block_hash_area(uint64_t height) const;
bool is_within_compiled_block_hash_area() const { return is_within_compiled_block_hash_area(m_db->height()); }
- uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes);
+ uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes, const std::vector<uint64_t> &weights);
uint32_t get_blockchain_pruning_seed() const { return m_db->get_blockchain_pruning_seed(); }
bool prune_blockchain(uint32_t pruning_seed = 0);
bool update_blockchain_pruning();
@@ -1000,6 +1001,21 @@ namespace cryptonote
*/
void pop_blocks(uint64_t nblocks);
+ /**
+ * @brief checks whether a given block height is included in the precompiled block hash area
+ *
+ * @param height the height to check for
+ */
+ bool is_within_compiled_block_hash_area(uint64_t height) const;
+
+ /**
+ * @brief checks whether we have known weights for the given block heights
+ *
+ * @param height the start height to check for
+ * @param nblocks how many blocks to check from that height
+ */
+ bool has_block_weights(uint64_t height, uint64_t nblocks) const;
+
#ifndef IN_UNIT_TESTS
private:
#endif
@@ -1027,8 +1043,8 @@ namespace cryptonote
std::unordered_map<crypto::hash, crypto::hash> m_blocks_longhash_table;
// SHA-3 hashes for each block and for fast pow checking
- std::vector<crypto::hash> m_blocks_hash_of_hashes;
- std::vector<crypto::hash> m_blocks_hash_check;
+ std::vector<std::pair<crypto::hash, crypto::hash>> m_blocks_hash_of_hashes;
+ std::vector<std::pair<crypto::hash, uint64_t>> m_blocks_hash_check;
std::vector<crypto::hash> m_blocks_txs_check;
blockchain_db_sync_mode m_db_sync_mode;