Skip to content

Commit

Permalink
Implement CInstantSendManager and related P2P messages
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Mar 7, 2019
1 parent 5bbc122 commit 83dbcc4
Show file tree
Hide file tree
Showing 11 changed files with 1,075 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ BITCOIN_CORE_H = \
llmq/quorums_dkgsessionmgr.h \
llmq/quorums_dkgsession.h \
llmq/quorums_init.h \
llmq/quorums_instantsend.h \
llmq/quorums_signing.h \
llmq/quorums_signing_shares.h \
llmq/quorums_utils.h \
Expand Down Expand Up @@ -291,6 +292,7 @@ libdash_server_a_SOURCES = \
llmq/quorums_dkgsessionmgr.cpp \
llmq/quorums_dkgsession.cpp \
llmq/quorums_init.cpp \
llmq/quorums_instantsend.cpp \
llmq/quorums_signing.cpp \
llmq/quorums_signing_shares.cpp \
llmq/quorums_utils.cpp \
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ class CDevNetParams : public CChainParams {
consensus.llmqs[Consensus::LLMQ_400_60] = llmq400_60;
consensus.llmqs[Consensus::LLMQ_400_85] = llmq400_85;
consensus.llmqChainLocks = Consensus::LLMQ_50_60;
consensus.llmqForInstantSend = Consensus::LLMQ_50_60;

fMiningRequiresPeers = true;
fDefaultConsistencyChecks = false;
Expand Down Expand Up @@ -787,6 +788,7 @@ class CRegTestParams : public CChainParams {
consensus.llmqs[Consensus::LLMQ_10_60] = llmq10_60;
consensus.llmqs[Consensus::LLMQ_50_60] = llmq50_60;
consensus.llmqChainLocks = Consensus::LLMQ_10_60;
consensus.llmqForInstantSend = Consensus::LLMQ_10_60;
}

void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int64_t nWindowSize, int64_t nThreshold)
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ struct Params {

std::map<LLMQType, LLMQParams> llmqs;
LLMQType llmqChainLocks;
LLMQType llmqForInstantSend{LLMQ_NONE};
};
} // namespace Consensus

Expand Down
7 changes: 7 additions & 0 deletions src/dsnotificationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "llmq/quorums.h"
#include "llmq/quorums_chainlocks.h"
#include "llmq/quorums_instantsend.h"
#include "llmq/quorums_dkgsessionmgr.h"

void CDSNotificationInterface::InitializeCurrentBlockTip()
Expand Down Expand Up @@ -72,6 +73,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con

void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock)
{
llmq::quorumInstantSendManager->SyncTransaction(tx, pindex, posInBlock);
instantsend.SyncTransaction(tx, pindex, posInBlock);
CPrivateSend::SyncTransaction(tx, pindex, posInBlock);
}
Expand All @@ -82,3 +84,8 @@ void CDSNotificationInterface::NotifyMasternodeListChanged(const CDeterministicM
governance.CheckMasternodeOrphanVotes(connman);
governance.UpdateCachesAndClean();
}

void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex)
{
llmq::quorumInstantSendManager->NotifyChainLock(pindex);
}
1 change: 1 addition & 0 deletions src/dsnotificationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CDSNotificationInterface : public CValidationInterface
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) override;
void NotifyMasternodeListChanged(const CDeterministicMNList& newList) override;
void NotifyChainLock(const CBlockIndex* pindex);

private:
CConnman& connman;
Expand Down
10 changes: 10 additions & 0 deletions src/llmq/quorums_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "quorums_chainlocks.h"
#include "quorums_debug.h"
#include "quorums_dkgsessionmgr.h"
#include "quorums_instantsend.h"
#include "quorums_signing.h"
#include "quorums_signing_shares.h"

Expand All @@ -29,10 +30,13 @@ void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests)
quorumSigSharesManager = new CSigSharesManager();
quorumSigningManager = new CSigningManager(unitTests);
chainLocksHandler = new CChainLocksHandler(scheduler);
quorumInstantSendManager = new CInstantSendManager(scheduler);
}

void DestroyLLMQSystem()
{
delete quorumInstantSendManager;
quorumInstantSendManager = nullptr;
delete chainLocksHandler;
chainLocksHandler = nullptr;
delete quorumSigningManager;
Expand Down Expand Up @@ -64,10 +68,16 @@ void StartLLMQSystem()
if (chainLocksHandler) {
chainLocksHandler->RegisterAsRecoveredSigsListener();
}
if (quorumInstantSendManager) {
quorumInstantSendManager->RegisterAsRecoveredSigsListener();
}
}

void StopLLMQSystem()
{
if (quorumInstantSendManager) {
quorumInstantSendManager->UnregisterAsRecoveredSigsListener();
}
if (chainLocksHandler) {
chainLocksHandler->UnregisterAsRecoveredSigsListener();
}
Expand Down
Loading

0 comments on commit 83dbcc4

Please sign in to comment.