mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Call and implemente new signals in CPrivateSend
Instead of relying on CDSNotificationInterface running compatibility code. This also removes locking of cs_main, as this seemed to be not needed.
This commit is contained in:
parent
816efa9cd4
commit
8df25bbfe4
@ -75,13 +75,13 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
|
||||
void CDSNotificationInterface::SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex, int posInBlock)
|
||||
{
|
||||
instantsend.SyncTransaction(tx, pindex, posInBlock);
|
||||
CPrivateSend::SyncTransaction(tx, pindex, posInBlock);
|
||||
}
|
||||
|
||||
void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx)
|
||||
{
|
||||
llmq::quorumInstantSendManager->TransactionAddedToMempool(ptx);
|
||||
llmq::chainLocksHandler->TransactionAddedToMempool(ptx);
|
||||
CPrivateSend::TransactionAddedToMempool(ptx);
|
||||
SyncTransaction(ptx);
|
||||
}
|
||||
|
||||
@ -97,6 +97,7 @@ void CDSNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock
|
||||
|
||||
llmq::quorumInstantSendManager->BlockConnected(pblock, pindex, vtxConflicted);
|
||||
llmq::chainLocksHandler->BlockConnected(pblock, pindex, vtxConflicted);
|
||||
CPrivateSend::BlockConnected(pblock, pindex, vtxConflicted);
|
||||
|
||||
for (const CTransactionRef& ptx : vtxConflicted) {
|
||||
SyncTransaction(ptx);
|
||||
@ -110,6 +111,7 @@ void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr<const CBl
|
||||
{
|
||||
llmq::quorumInstantSendManager->BlockDisconnected(pblock, pindexDisconnected);
|
||||
llmq::chainLocksHandler->BlockDisconnected(pblock, pindexDisconnected);
|
||||
CPrivateSend::BlockDisconnected(pblock, pindexDisconnected);
|
||||
|
||||
for (const CTransactionRef& ptx : pblock->vtx) {
|
||||
SyncTransaction(ptx, pindexDisconnected->pprev, -1);
|
||||
|
@ -509,16 +509,39 @@ void CPrivateSend::UpdatedBlockTip(const CBlockIndex* pindex)
|
||||
}
|
||||
}
|
||||
|
||||
void CPrivateSend::SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex, int posInBlock)
|
||||
void CPrivateSend::UpdateDSTXConfirmedHeight(const CTransactionRef& tx, int nHeight)
|
||||
{
|
||||
if (tx->IsCoinBase()) return;
|
||||
|
||||
LOCK2(cs_main, cs_mapdstx);
|
||||
AssertLockHeld(cs_mapdstx);
|
||||
|
||||
uint256 txHash = tx->GetHash();
|
||||
if (!mapDSTX.count(txHash)) return;
|
||||
|
||||
// When tx is 0-confirmed or conflicted, posInBlock is SYNC_TRANSACTION_NOT_IN_BLOCK and nConfirmedHeight should be set to -1
|
||||
mapDSTX[txHash].SetConfirmedHeight((posInBlock == -1 || pindex == nullptr) ? -1 : pindex->nHeight);
|
||||
LogPrint(BCLog::PRIVATESEND, "CPrivateSend::SyncTransaction -- txid=%s\n", txHash.ToString());
|
||||
mapDSTX[txHash].SetConfirmedHeight(nHeight);
|
||||
LogPrint(BCLog::PRIVATESEND, "CPrivateSend::%s -- txid=%s, nHeight=%d\n", __func__, txHash.ToString(), nHeight);
|
||||
}
|
||||
|
||||
void CPrivateSend::TransactionAddedToMempool(const CTransactionRef& tx)
|
||||
{
|
||||
LOCK(cs_mapdstx);
|
||||
UpdateDSTXConfirmedHeight(tx, -1);
|
||||
}
|
||||
|
||||
void CPrivateSend::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
|
||||
{
|
||||
LOCK(cs_mapdstx);
|
||||
for (const auto& tx : vtxConflicted) {
|
||||
UpdateDSTXConfirmedHeight(tx, -1);
|
||||
}
|
||||
|
||||
for (const auto& tx : pblock->vtx) {
|
||||
UpdateDSTXConfirmedHeight(tx, pindex->nHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void CPrivateSend::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected)
|
||||
{
|
||||
LOCK(cs_mapdstx);
|
||||
for (const auto& tx : pblock->vtx) {
|
||||
UpdateDSTXConfirmedHeight(tx, -1);
|
||||
}
|
||||
}
|
||||
|
@ -422,7 +422,12 @@ public:
|
||||
static CPrivateSendBroadcastTx GetDSTX(const uint256& hash);
|
||||
|
||||
static void UpdatedBlockTip(const CBlockIndex* pindex);
|
||||
static void SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex = nullptr, int posInBlock = 0);
|
||||
|
||||
static void UpdateDSTXConfirmedHeight(const CTransactionRef& tx, int nHeight);
|
||||
static void TransactionAddedToMempool(const CTransactionRef& tx);
|
||||
static void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted);
|
||||
static void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user