mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Add helper to see if a peer is registered for reconciliations
This commit is contained in:
parent
4470acf076
commit
36cf6bf216
2 changed files with 19 additions and 0 deletions
|
@ -63,6 +63,15 @@ public:
|
|||
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>()} {}
|
||||
|
@ -78,3 +87,8 @@ void TxReconciliationTracker::ForgetPeer(NodeId 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.
|
||||
*/
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue