mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-01 03:01:09 +02:00
Add helper to see if a peer is registered for reconciliations
This commit is contained in:
@ -63,6 +63,15 @@ public:
|
|||||||
LogPrintLevel(BCLog::TXRECONCILIATION, BCLog::Level::Debug, "Forget txreconciliation state of peer=%d\n", peer_id);
|
LogPrintLevel(BCLog::TXRECONCILIATION, BCLog::Level::Debug, "Forget txreconciliation state of peer=%d\n", peer_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsPeerRegistered(NodeId peer_id) const EXCLUSIVE_LOCKS_REQUIRED(!m_txreconciliation_mutex)
|
||||||
|
{
|
||||||
|
AssertLockNotHeld(m_txreconciliation_mutex);
|
||||||
|
LOCK(m_txreconciliation_mutex);
|
||||||
|
auto recon_state = m_states.find(peer_id);
|
||||||
|
return (recon_state != m_states.end() &&
|
||||||
|
std::holds_alternative<TxReconciliationState>(recon_state->second));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TxReconciliationTracker::TxReconciliationTracker() : m_impl{std::make_unique<TxReconciliationTracker::Impl>()} {}
|
TxReconciliationTracker::TxReconciliationTracker() : m_impl{std::make_unique<TxReconciliationTracker::Impl>()} {}
|
||||||
@ -78,3 +87,8 @@ void TxReconciliationTracker::ForgetPeer(NodeId peer_id)
|
|||||||
{
|
{
|
||||||
m_impl->ForgetPeer(peer_id);
|
m_impl->ForgetPeer(peer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TxReconciliationTracker::IsPeerRegistered(NodeId peer_id) const
|
||||||
|
{
|
||||||
|
return m_impl->IsPeerRegistered(peer_id);
|
||||||
|
}
|
||||||
|
@ -67,6 +67,11 @@ public:
|
|||||||
* After this, we won't be able to reconcile transactions with the peer.
|
* After this, we won't be able to reconcile transactions with the peer.
|
||||||
*/
|
*/
|
||||||
void ForgetPeer(NodeId peer_id);
|
void ForgetPeer(NodeId peer_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a peer is registered to reconcile transactions with us.
|
||||||
|
*/
|
||||||
|
bool IsPeerRegistered(NodeId peer_id) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_NODE_TXRECONCILIATION_H
|
#endif // BITCOIN_NODE_TXRECONCILIATION_H
|
||||||
|
Reference in New Issue
Block a user