Fix repairwallet to update walletmodel without restart.
authoralex <alex@alex-VirtualBox.(none)>
Fri, 24 Jan 2014 17:46:39 +0000 (21:46 +0400)
committeralex <alex@alex-VirtualBox.(none)>
Fri, 24 Jan 2014 17:46:39 +0000 (21:46 +0400)
src/main.cpp
src/wallet.cpp

index 11f2f10..dc9a84b 100644 (file)
@@ -1675,6 +1675,9 @@ bool CBlock::DisconnectBlock(CBlockIndex *pindex, CCoinsViewCache &view)
                     return error("DisconnectBlock() : cannot restore coin inputs");
             }
         }
+
+        // clean up wallet after disconnecting coinstake
+        SyncWithWallets(vtx[i].GetHash(), vtx[i], this, true, false);
     }
 
     // move best block pointer to prevout block
@@ -1870,12 +1873,12 @@ bool SetBestChain(CBlockIndex* pindexNew)
     BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) {
         CBlock block;
         if (!block.ReadFromDisk(pindex))
-            return error("SetBestBlock() : ReadFromDisk for disconnect failed");
+            return error("SetBestChain() : ReadFromDisk for disconnect failed");
         CCoinsViewCache viewTemp(view, true);
         if (!block.DisconnectBlock(pindex, viewTemp))
-            return error("SetBestBlock() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
+            return error("SetBestChain() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
         if (!viewTemp.Flush())
-            return error("SetBestBlock() : Cache flush failed after disconnect");
+            return error("SetBestChain() : Cache flush failed after disconnect");
 
         // Queue memory transactions to resurrect
         BOOST_FOREACH(const CTransaction& tx, block.vtx)
@@ -1888,15 +1891,15 @@ bool SetBestChain(CBlockIndex* pindexNew)
     BOOST_FOREACH(CBlockIndex *pindex, vConnect) {
         CBlock block;
         if (!block.ReadFromDisk(pindex))
-            return error("SetBestBlock() : ReadFromDisk for connect failed");
+            return error("SetBestChain() : ReadFromDisk for connect failed");
         CCoinsViewCache viewTemp(view, true);
         if (!block.ConnectBlock(pindex, viewTemp)) {
             InvalidChainFound(pindexNew);
             InvalidBlockFound(pindex);
-            return error("SetBestBlock() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
+            return error("SetBestChain() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
         }
         if (!viewTemp.Flush())
-            return error("SetBestBlock() : Cache flush failed after connect");
+            return error("SetBestChain() : Cache flush failed after connect");
 
         // Queue memory transactions to delete
         BOOST_FOREACH(const CTransaction& tx, block.vtx)
index 4eef99e..a7663fa 100644 (file)
@@ -850,7 +850,7 @@ void CWallet::ReacceptWalletTransactions()
                 }
                 if (fUpdated)
                 {
-                    printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
+                    printf("ReacceptWalletTransactions found spent coin %snvc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
                     wtx.MarkDirty();
                     wtx.WriteToDisk();
                 }
@@ -2265,6 +2265,8 @@ void CWallet::FixSpentCoins(int& nMismatchFound, int64& nBalanceInQuestion, bool
                         pcoin->WriteToDisk();
                     }
                 }
+
+                NotifyTransactionChanged(this, hash, CT_UPDATED);
             }
         }