mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
Add blink HF version checks
This commit is contained in:
parent
5a81cd820e
commit
24aadd8e59
|
@ -1974,7 +1974,15 @@ bool Blockchain::handle_get_blocks(NOTIFY_REQUEST_GET_BLOCKS::request& arg, NOTI
|
|||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
std::unique_lock<decltype(m_blockchain_lock)> blockchain_lock{m_blockchain_lock, std::defer_lock};
|
||||
auto blink_lock = m_tx_pool.blink_shared_lock(std::defer_lock);
|
||||
std::lock(blockchain_lock, blink_lock);
|
||||
bool blink_enabled = false;
|
||||
if (get_current_hard_fork_version() >= HF_VERSION_BLINK)
|
||||
{
|
||||
blink_enabled = true;
|
||||
std::lock(blockchain_lock, blink_lock);
|
||||
}
|
||||
else
|
||||
blockchain_lock.lock();
|
||||
|
||||
db_rtxn_guard rtxn_guard (m_db);
|
||||
rsp.current_blockchain_height = get_current_blockchain_height();
|
||||
std::vector<std::pair<cryptonote::blobdata,block>> blocks;
|
||||
|
@ -2019,13 +2027,16 @@ bool Blockchain::handle_get_blocks(NOTIFY_REQUEST_GET_BLOCKS::request& arg, NOTI
|
|||
std::vector<crypto::hash> missed_tx_ids;
|
||||
get_transactions_blobs(block.tx_hashes, block_entry.txs, missed_tx_ids);
|
||||
|
||||
for (auto &h : block.tx_hashes)
|
||||
if (blink_enabled)
|
||||
{
|
||||
if (auto blink = m_tx_pool.get_blink(h))
|
||||
for (auto &h : block.tx_hashes)
|
||||
{
|
||||
auto l = blink->shared_lock();
|
||||
block_entry.blinks.emplace_back();
|
||||
blink->fill_serialization_data(block_entry.blinks.back());
|
||||
if (auto blink = m_tx_pool.get_blink(h))
|
||||
{
|
||||
auto l = blink->shared_lock();
|
||||
block_entry.blinks.emplace_back();
|
||||
blink->fill_serialization_data(block_entry.blinks.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2052,7 +2063,15 @@ bool Blockchain::handle_get_txs(NOTIFY_REQUEST_GET_TXS::request& arg, NOTIFY_NEW
|
|||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
std::unique_lock<decltype(m_blockchain_lock)> blockchain_lock{m_blockchain_lock, std::defer_lock};
|
||||
auto blink_lock = m_tx_pool.blink_shared_lock(std::defer_lock);
|
||||
std::lock(blockchain_lock, blink_lock);
|
||||
bool blink_enabled = false;
|
||||
if (get_current_hard_fork_version() >= HF_VERSION_BLINK)
|
||||
{
|
||||
blink_enabled = true;
|
||||
std::lock(blockchain_lock, blink_lock);
|
||||
}
|
||||
else
|
||||
blockchain_lock.lock();
|
||||
|
||||
db_rtxn_guard rtxn_guard (m_db);
|
||||
std::vector<std::pair<cryptonote::blobdata,block>> blocks;
|
||||
std::vector<crypto::hash> ignore_missed;
|
||||
|
@ -2066,13 +2085,16 @@ bool Blockchain::handle_get_txs(NOTIFY_REQUEST_GET_TXS::request& arg, NOTIFY_NEW
|
|||
ignore_missed.clear();
|
||||
}
|
||||
|
||||
for (auto &h : arg.txs)
|
||||
if (blink_enabled)
|
||||
{
|
||||
if (auto blink = m_tx_pool.get_blink(h))
|
||||
for (auto &h : arg.txs)
|
||||
{
|
||||
rsp.blinks.emplace_back();
|
||||
auto l = blink->shared_lock();
|
||||
blink->fill_serialization_data(rsp.blinks.back());
|
||||
if (auto blink = m_tx_pool.get_blink(h))
|
||||
{
|
||||
rsp.blinks.emplace_back();
|
||||
auto l = blink->shared_lock();
|
||||
blink->fill_serialization_data(rsp.blinks.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1183,8 +1183,6 @@ namespace cryptonote
|
|||
if (!results[i].res)
|
||||
continue;
|
||||
|
||||
if (tx_hashes) (*tx_hashes)[i] = results[i].hash;
|
||||
|
||||
if(m_mempool.have_tx(results[i].hash))
|
||||
{
|
||||
LOG_PRINT_L2("tx " << results[i].hash << "already have transaction in tx_pool");
|
||||
|
@ -1245,6 +1243,9 @@ namespace cryptonote
|
|||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::handle_incoming_blinks(const std::vector<serializable_blink_metadata> &blinks, std::vector<crypto::hash> *bad_blinks, std::vector<crypto::hash> *missing_txs)
|
||||
{
|
||||
if (m_blockchain_storage.get_current_hard_fork_version() < HF_VERSION_BLINK)
|
||||
return true;
|
||||
|
||||
std::vector<uint8_t> store_blink(blinks.size(), false);
|
||||
size_t store_count = 0;
|
||||
// Step 1: figure out which referenced transactions we have and want blink info for (i.e. mined
|
||||
|
|
|
@ -378,6 +378,7 @@ namespace cryptonote
|
|||
|
||||
context.m_need_blink_sync = false;
|
||||
// Check for any blink txes being advertised that we don't know about
|
||||
if (m_core.get_blockchain_storage().get_current_hard_fork_version() >= HF_VERSION_BLINK)
|
||||
{
|
||||
if (hshd.blink_blocks.size() != hshd.blink_hash.size())
|
||||
{
|
||||
|
@ -2414,6 +2415,7 @@ skip:
|
|||
// blink data that got sent to us (we may have additional blink info, or may have rejected some
|
||||
// of the incoming blink data).
|
||||
arg.blinks.clear();
|
||||
if (m_core.get_blockchain_storage().get_current_hard_fork_version() >= HF_VERSION_BLINK)
|
||||
{
|
||||
auto &pool = m_core.get_pool();
|
||||
auto lock = pool.blink_shared_lock();
|
||||
|
|
|
@ -721,6 +721,7 @@ namespace cryptonote
|
|||
}
|
||||
}
|
||||
|
||||
if (m_core.get_blockchain_storage().get_current_hard_fork_version() >= HF_VERSION_BLINK)
|
||||
{
|
||||
auto &pool = m_core.get_pool();
|
||||
auto lock = pool.blink_shared_lock();
|
||||
|
|
Loading…
Reference in a new issue