Add listener interface to listen for recovered sigs
This commit is contained in:
parent
189cee2108
commit
9f211ef12d
@ -414,8 +414,10 @@ void CSigningManager::ProcessRecoveredSig(NodeId nodeId, const CRecoveredSig& re
|
|||||||
connman.RemoveAskFor(recoveredSig.GetHash());
|
connman.RemoveAskFor(recoveredSig.GetHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CRecoveredSigsListener*> listeners;
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
listeners = recoveredSigsListeners;
|
||||||
|
|
||||||
auto signHash = CLLMQUtils::BuildSignHash(recoveredSig);
|
auto signHash = CLLMQUtils::BuildSignHash(recoveredSig);
|
||||||
|
|
||||||
@ -435,6 +437,10 @@ void CSigningManager::ProcessRecoveredSig(NodeId nodeId, const CRecoveredSig& re
|
|||||||
|
|
||||||
CInv inv(MSG_QUORUM_RECOVERED_SIG, recoveredSig.GetHash());
|
CInv inv(MSG_QUORUM_RECOVERED_SIG, recoveredSig.GetHash());
|
||||||
g_connman->RelayInv(inv);
|
g_connman->RelayInv(inv);
|
||||||
|
|
||||||
|
for (auto& l : listeners) {
|
||||||
|
l->HandleNewRecoveredSig(recoveredSig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSigningManager::Cleanup()
|
void CSigningManager::Cleanup()
|
||||||
@ -451,6 +457,19 @@ void CSigningManager::Cleanup()
|
|||||||
lastCleanupTime = GetTimeMillis();
|
lastCleanupTime = GetTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSigningManager::RegisterRecoveredSigsListener(CRecoveredSigsListener* l)
|
||||||
|
{
|
||||||
|
LOCK(cs);
|
||||||
|
recoveredSigsListeners.emplace_back(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSigningManager::UnregisterRecoveredSigsListener(CRecoveredSigsListener* l)
|
||||||
|
{
|
||||||
|
LOCK(cs);
|
||||||
|
auto itRem = std::remove(recoveredSigsListeners.begin(), recoveredSigsListeners.end(), l);
|
||||||
|
recoveredSigsListeners.erase(itRem, recoveredSigsListeners.end());
|
||||||
|
}
|
||||||
|
|
||||||
bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash)
|
bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash)
|
||||||
{
|
{
|
||||||
auto& params = Params().GetConsensus().llmqs.at(llmqType);
|
auto& params = Params().GetConsensus().llmqs.at(llmqType);
|
||||||
|
@ -91,6 +91,14 @@ private:
|
|||||||
bool ReadRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, CRecoveredSig& ret);
|
bool ReadRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, CRecoveredSig& ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CRecoveredSigsListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~CRecoveredSigsListener() {}
|
||||||
|
|
||||||
|
virtual void HandleNewRecoveredSig(const CRecoveredSig& recoveredSig) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class CSigningManager
|
class CSigningManager
|
||||||
{
|
{
|
||||||
friend class CSigSharesManager;
|
friend class CSigSharesManager;
|
||||||
@ -109,6 +117,8 @@ private:
|
|||||||
|
|
||||||
int64_t lastCleanupTime{0};
|
int64_t lastCleanupTime{0};
|
||||||
|
|
||||||
|
std::vector<CRecoveredSigsListener*> recoveredSigsListeners;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSigningManager(bool fMemory);
|
CSigningManager(bool fMemory);
|
||||||
|
|
||||||
@ -128,6 +138,9 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// public interface
|
// public interface
|
||||||
|
void RegisterRecoveredSigsListener(CRecoveredSigsListener* l);
|
||||||
|
void UnregisterRecoveredSigsListener(CRecoveredSigsListener* l);
|
||||||
|
|
||||||
bool AsyncSignIfMember(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash);
|
bool AsyncSignIfMember(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash);
|
||||||
bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash);
|
bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash);
|
||||||
bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id);
|
bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id);
|
||||||
|
Loading…
Reference in New Issue
Block a user