port expired transaction notify from Zcash. Issue #110
This commit is contained in:
11
src/init.cpp
11
src/init.cpp
@@ -399,6 +399,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), "komodod.pid"));
|
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), "komodod.pid"));
|
||||||
#endif
|
#endif
|
||||||
|
strUsage += HelpMessageOpt("-txexpirynotify=<cmd>", _("Execute command when transaction expires (%s in cmd is replaced by transaction id)"));
|
||||||
strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. "
|
strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. "
|
||||||
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
|
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
|
||||||
"(default: 0 = disable pruning blocks, >%u = target size in MiB to use for block files)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
|
"(default: 0 = disable pruning blocks, >%u = target size in MiB to use for block files)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
|
||||||
@@ -618,6 +619,14 @@ static void BlockNotifyCallback(const uint256& hashNewTip)
|
|||||||
boost::thread t(runCommand, strCmd); // thread runs free
|
boost::thread t(runCommand, strCmd); // thread runs free
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TxExpiryNotifyCallback(const uint256& txid)
|
||||||
|
{
|
||||||
|
std::string strCmd = GetArg("-txexpirynotify", "");
|
||||||
|
|
||||||
|
boost::replace_all(strCmd, "%s", txid.GetHex());
|
||||||
|
boost::thread t(runCommand, strCmd); // thread runs free
|
||||||
|
}
|
||||||
|
|
||||||
struct CImportingNow
|
struct CImportingNow
|
||||||
{
|
{
|
||||||
CImportingNow() {
|
CImportingNow() {
|
||||||
@@ -2114,6 +2123,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
if (mapArgs.count("-blocknotify"))
|
if (mapArgs.count("-blocknotify"))
|
||||||
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
||||||
|
if (mapArgs.count("-txexpirynotify"))
|
||||||
|
uiInterface.NotifyTxExpiration.connect(TxExpiryNotifyCallback);
|
||||||
if ( KOMODO_REWIND >= 0 )
|
if ( KOMODO_REWIND >= 0 )
|
||||||
{
|
{
|
||||||
uiInterface.InitMessage(_("Activating best chain..."));
|
uiInterface.InitMessage(_("Activating best chain..."));
|
||||||
|
|||||||
@@ -4210,7 +4210,11 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
|||||||
mempool.removeForBlock(pblock->vtx, pindexNew->GetHeight(), txConflicted, !IsInitialBlockDownload());
|
mempool.removeForBlock(pblock->vtx, pindexNew->GetHeight(), txConflicted, !IsInitialBlockDownload());
|
||||||
|
|
||||||
// Remove transactions that expire at new block height from mempool
|
// Remove transactions that expire at new block height from mempool
|
||||||
mempool.removeExpired(pindexNew->GetHeight());
|
auto ids = mempool.removeExpired(pindexNew->GetHeight());
|
||||||
|
|
||||||
|
for (auto id : ids) {
|
||||||
|
uiInterface.NotifyTxExpiration(id);
|
||||||
|
}
|
||||||
|
|
||||||
// Update chainActive & related variables.
|
// Update chainActive & related variables.
|
||||||
UpdateTip(pindexNew);
|
UpdateTip(pindexNew);
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
|
|||||||
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
|
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
|
||||||
extern char ASSETCHAINS_SYMBOL[];
|
extern char ASSETCHAINS_SYMBOL[];
|
||||||
|
|
||||||
void CTxMemPool::removeExpired(unsigned int nBlockHeight)
|
std::vector<uint256> CTxMemPool::removeExpired(unsigned int nBlockHeight)
|
||||||
{
|
{
|
||||||
CBlockIndex *tipindex;
|
CBlockIndex *tipindex;
|
||||||
// Remove expired txs from the mempool
|
// Remove expired txs from the mempool
|
||||||
@@ -528,11 +528,14 @@ void CTxMemPool::removeExpired(unsigned int nBlockHeight)
|
|||||||
transactionsToRemove.push_back(tx);
|
transactionsToRemove.push_back(tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::vector<uint256> ids;
|
||||||
for (const CTransaction& tx : transactionsToRemove) {
|
for (const CTransaction& tx : transactionsToRemove) {
|
||||||
list<CTransaction> removed;
|
list<CTransaction> removed;
|
||||||
remove(tx, removed, true);
|
remove(tx, removed, true);
|
||||||
|
ids.push_back(tx.GetHash());
|
||||||
LogPrint("mempool", "Removing expired txid: %s\n", tx.GetHash().ToString());
|
LogPrint("mempool", "Removing expired txid: %s\n", tx.GetHash().ToString());
|
||||||
}
|
}
|
||||||
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public:
|
|||||||
void removeWithAnchor(const uint256 &invalidRoot, ShieldedType type);
|
void removeWithAnchor(const uint256 &invalidRoot, ShieldedType type);
|
||||||
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
|
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
|
||||||
void removeConflicts(const CTransaction &tx, std::list<CTransaction>& removed);
|
void removeConflicts(const CTransaction &tx, std::list<CTransaction>& removed);
|
||||||
void removeExpired(unsigned int nBlockHeight);
|
std::vector<uint256> removeExpired(unsigned int nBlockHeight);
|
||||||
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
|
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
|
||||||
std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);
|
std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);
|
||||||
void removeWithoutBranchId(uint32_t nMemPoolBranchId);
|
void removeWithoutBranchId(uint32_t nMemPoolBranchId);
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ public:
|
|||||||
|
|
||||||
/** New block has been accepted */
|
/** New block has been accepted */
|
||||||
boost::signals2::signal<void (const uint256& hash)> NotifyBlockTip;
|
boost::signals2::signal<void (const uint256& hash)> NotifyBlockTip;
|
||||||
|
|
||||||
|
/** Transaction expired */
|
||||||
|
boost::signals2::signal<void (const uint256& txid)> NotifyTxExpiration;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CClientUIInterface uiInterface;
|
extern CClientUIInterface uiInterface;
|
||||||
|
|||||||
Reference in New Issue
Block a user