Erase failed stake transaction from wallet to prevent slow return and loss of stake age
This commit is contained in:
17
src/main.cpp
17
src/main.cpp
@@ -3148,9 +3148,11 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
|||||||
CTransaction &tx = block.vtx[i];
|
CTransaction &tx = block.vtx[i];
|
||||||
list<CTransaction> removed;
|
list<CTransaction> removed;
|
||||||
CValidationState stateDummy;
|
CValidationState stateDummy;
|
||||||
// don't keep staking transactions
|
// don't keep staking or invalid transactions
|
||||||
if (tx.IsCoinBase() || (block.IsVerusPOSBlock() && (i == (block.vtx.size() - 1))) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
if (tx.IsCoinBase() || (block.IsVerusPOSBlock() && (i == (block.vtx.size() - 1))) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
||||||
|
{
|
||||||
mempool.remove(tx, removed, true);
|
mempool.remove(tx, removed, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (anchorBeforeDisconnect != anchorAfterDisconnect) {
|
if (anchorBeforeDisconnect != anchorAfterDisconnect) {
|
||||||
// The anchor may not change between block disconnects,
|
// The anchor may not change between block disconnects,
|
||||||
@@ -3166,8 +3168,17 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
|||||||
assert(pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), newTree));
|
assert(pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), newTree));
|
||||||
// Let wallets know transactions went from 1-confirmed to
|
// Let wallets know transactions went from 1-confirmed to
|
||||||
// 0-confirmed or conflicted:
|
// 0-confirmed or conflicted:
|
||||||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
for (int i = 0; i < block.vtx.size(); i++)
|
||||||
SyncWithWallets(tx, NULL);
|
{
|
||||||
|
CTransaction &tx = block.vtx[i];
|
||||||
|
if (block.IsVerusPOSBlock() && (i == (block.vtx.size() - 1)))
|
||||||
|
{
|
||||||
|
EraseFromWallets(tx.GetHash());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SyncWithWallets(tx, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Update cached incremental witnesses
|
// Update cached incremental witnesses
|
||||||
//fprintf(stderr,"chaintip false\n");
|
//fprintf(stderr,"chaintip false\n");
|
||||||
|
|||||||
@@ -51,3 +51,7 @@ void UnregisterAllValidationInterfaces() {
|
|||||||
void SyncWithWallets(const CTransaction &tx, const CBlock *pblock) {
|
void SyncWithWallets(const CTransaction &tx, const CBlock *pblock) {
|
||||||
g_signals.SyncTransaction(tx, pblock);
|
g_signals.SyncTransaction(tx, pblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EraseFromWallets(const uint256 &hash) {
|
||||||
|
g_signals.EraseTransaction(hash);
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn);
|
|||||||
void UnregisterAllValidationInterfaces();
|
void UnregisterAllValidationInterfaces();
|
||||||
/** Push an updated transaction to all registered wallets */
|
/** Push an updated transaction to all registered wallets */
|
||||||
void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL);
|
void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL);
|
||||||
|
/** Erase a transaction from all registered wallets */
|
||||||
|
void EraseFromWallets(const uint256 &hash);
|
||||||
|
|
||||||
class CValidationInterface {
|
class CValidationInterface {
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user