Update Dash related code to use new SyncTransaction notifications interface

This commit is contained in:
Alexander Block 2018-01-08 18:41:06 +01:00
parent ebc466dbd5
commit e3da73ebf8
6 changed files with 12 additions and 34 deletions

View File

@ -53,8 +53,8 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
governance.UpdatedBlockTip(pindexNew, connman);
}
void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, const CBlock *pblock)
void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock)
{
instantsend.SyncTransaction(tx, pblock);
CPrivateSend::SyncTransaction(tx, pblock);
instantsend.SyncTransaction(tx, pindex, posInBlock);
CPrivateSend::SyncTransaction(tx, pindex, posInBlock);
}

View File

@ -21,7 +21,7 @@ protected:
void AcceptedBlockHeader(const CBlockIndex *pindexNew) override;
void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload) override;
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, const CBlock *pblock);
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock);
private:
CConnman& connman;

View File

@ -860,7 +860,7 @@ void CInstantSend::UpdatedBlockTip(const CBlockIndex *pindex)
nCachedBlockHeight = pindex->nHeight;
}
void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlockIndex *pindex, int posInBlock)
{
// Update lock candidates and votes if corresponding tx confirmed
// or went from confirmed to 0-confirmed or conflicted.
@ -871,19 +871,8 @@ void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
uint256 txHash = tx.GetHash();
// When tx is 0-confirmed or conflicted, pblock is NULL and nHeightNew should be set to -1
CBlockIndex* pblockindex = NULL;
if(pblock) {
uint256 blockHash = pblock->GetHash();
BlockMap::iterator mi = mapBlockIndex.find(blockHash);
if(mi == mapBlockIndex.end() || !mi->second) {
// shouldn't happen
LogPrint("instantsend", "CTxLockRequest::SyncTransaction -- Failed to find block %s\n", blockHash.ToString());
return;
}
pblockindex = mi->second;
}
int nHeightNew = pblockindex ? pblockindex->nHeight : -1;
// When tx is 0-confirmed or conflicted, posInBlock is SYNC_TRANSACTION_NOT_IN_BLOCK and nHeightNew should be set to -1
int nHeightNew = posInBlock == CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK ? -1 : pindex->nHeight;
LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d\n", txHash.ToString(), nHeightNew);

View File

@ -114,7 +114,7 @@ public:
void Relay(const uint256& txHash, CConnman& connman);
void UpdatedBlockTip(const CBlockIndex *pindex);
void SyncTransaction(const CTransaction& tx, const CBlock* pblock);
void SyncTransaction(const CTransaction& tx, const CBlockIndex *pindex, int posInBlock);
std::string ToString();
};

View File

@ -410,7 +410,7 @@ void CPrivateSend::UpdatedBlockTip(const CBlockIndex *pindex)
}
}
void CPrivateSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
void CPrivateSend::SyncTransaction(const CTransaction& tx, const CBlockIndex *pindex, int posInBlock)
{
if (tx.IsCoinBase()) return;
@ -419,19 +419,8 @@ void CPrivateSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
uint256 txHash = tx.GetHash();
if (!mapDSTX.count(txHash)) return;
// When tx is 0-confirmed or conflicted, pblock is NULL and nConfirmedHeight should be set to -1
CBlockIndex* pblockindex = NULL;
if(pblock) {
uint256 blockHash = pblock->GetHash();
BlockMap::iterator mi = mapBlockIndex.find(blockHash);
if(mi == mapBlockIndex.end() || !mi->second) {
// shouldn't happen
LogPrint("privatesend", "CPrivateSendClient::SyncTransaction -- Failed to find block %s\n", blockHash.ToString());
return;
}
pblockindex = mi->second;
}
mapDSTX[txHash].SetConfirmedHeight(pblockindex ? pblockindex->nHeight : -1);
// 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 == CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK ? -1 : pindex->nHeight);
LogPrint("privatesend", "CPrivateSendClient::SyncTransaction -- txid=%s\n", txHash.ToString());
}

View File

@ -353,7 +353,7 @@ public:
static CDarksendBroadcastTx GetDSTX(const uint256& hash);
static void UpdatedBlockTip(const CBlockIndex *pindex);
static void SyncTransaction(const CTransaction& tx, const CBlock* pblock);
static void SyncTransaction(const CTransaction& tx, const CBlockIndex *pindex, int posInBlock);
};
void ThreadCheckPrivateSend(CConnman& connman);