Call new signals instead of SyncTransaction on CInstantSendManager

This commit moves all logic of SyncTransaction into ProcessNewTransaction
and then calls it from TransactionAddedToMempool and BlockConnected.

This won't compile/work at first, but the next commits will fix this.
This commit is contained in:
Alexander Block 2019-05-27 13:35:22 +02:00
parent 6afa605f6f
commit b36f0a324f
3 changed files with 30 additions and 3 deletions

View File

@ -74,7 +74,6 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
void CDSNotificationInterface::SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex, int posInBlock)
{
llmq::quorumInstantSendManager->SyncTransaction(tx, pindex, posInBlock);
llmq::chainLocksHandler->SyncTransaction(tx, pindex, posInBlock);
instantsend.SyncTransaction(tx, pindex, posInBlock);
CPrivateSend::SyncTransaction(tx, pindex, posInBlock);
@ -82,6 +81,7 @@ void CDSNotificationInterface::SyncTransaction(const CTransactionRef& tx, const
void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx)
{
llmq::quorumInstantSendManager->TransactionAddedToMempool(ptx);
SyncTransaction(ptx);
}
@ -95,6 +95,8 @@ void CDSNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock
// to abandon a transaction and then have it inadvertantly cleared by
// the notification that the conflicted transaction was evicted.
llmq::quorumInstantSendManager->BlockConnected(pblock, pindex, vtxConflicted);
for (const CTransactionRef& ptx : vtxConflicted) {
SyncTransaction(ptx);
}
@ -105,6 +107,8 @@ void CDSNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock
void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected)
{
llmq::quorumInstantSendManager->BlockDisconnected(pblock, pindexDisconnected);
for (const CTransactionRef& ptx : pblock->vtx) {
SyncTransaction(ptx, pindexDisconnected->pprev, -1);
}

View File

@ -949,7 +949,7 @@ void CInstantSendManager::UpdateWalletTransaction(const CTransactionRef& tx, con
mempool.AddTransactionsUpdated(1);
}
void CInstantSendManager::SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex, int posInBlock)
void CInstantSendManager::ProcessNewTransaction(const CTransactionRef& tx, const CBlockIndex* pindex)
{
if (!IsNewInstantSendEnabled()) {
return;
@ -1008,6 +1008,26 @@ void CInstantSendManager::SyncTransaction(const CTransactionRef& tx, const CBloc
}
}
void CInstantSendManager::TransactionAddedToMempool(const CTransactionRef& tx)
{
ProcessNewTransaction(tx, nullptr);
}
void CInstantSendManager::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
{
if (!IsNewInstantSendEnabled()) {
return;
}
for (const auto& tx : pblock->vtx) {
ProcessNewTransaction(tx, pindex);
}
}
void CInstantSendManager::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected)
{
}
void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx)
{
AssertLockHeld(cs);

View File

@ -141,7 +141,10 @@ public:
void ProcessInstantSendLock(NodeId from, const uint256& hash, const CInstantSendLock& islock);
void UpdateWalletTransaction(const CTransactionRef& tx, const CInstantSendLock& islock);
void SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex = nullptr, int posInBlock = 0);
void ProcessNewTransaction(const CTransactionRef& tx, const CBlockIndex* pindex);
void TransactionAddedToMempool(const CTransactionRef& tx);
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted);
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected);
void AddNonLockedTx(const CTransactionRef& tx);
void RemoveNonLockedTx(const uint256& txid, bool retryChildren);
void RemoveConflictedTx(const CTransaction& tx);