@@ -119,6 +119,7 @@ void CzPIVWallet::SyncWithChain(bool fGenerateMintPool)
119119 CWalletDB walletdb (strWalletFile);
120120 CzPIVTracker* zpivTracker = pwalletMain->zpivTracker ;
121121 std::set<uint256> setChecked;
122+ set<uint256> setAddedTx;
122123 while (found) {
123124 found = false ;
124125 if (fGenerateMintPool )
@@ -190,24 +191,23 @@ void CzPIVWallet::SyncWithChain(bool fGenerateMintPool)
190191 break ;
191192 }
192193
193- CBlock block;
194- CWalletTx wtx (pwalletMain, tx);
195- if (mapBlockIndex.count (hashBlock) && ReadBlockFromDisk (block, mapBlockIndex.at (hashBlock)))
196- wtx.SetMerkleBranch (block);
197-
198- // The mint was found in the chain, so recalculate the randomness and serial and DB it
199- int nHeight = 0 ;
200- int nTimeReceived = 0 ;
201- if (mapBlockIndex.count (hashBlock)) {
202- nHeight = mapBlockIndex.at (hashBlock)->nHeight ;
203- nTimeReceived = mapBlockIndex.at (hashBlock)->nTime ;
204- }
194+ CBlockIndex* pindex;
195+ if (mapBlockIndex.count (hashBlock))
196+ pindex = mapBlockIndex.at (hashBlock);
197+
198+ if (!setAddedTx.count (txHash)) {
199+ CBlock block;
200+ CWalletTx wtx (pwalletMain, tx);
201+ if (pindex && ReadBlockFromDisk (block, pindex))
202+ wtx.SetMerkleBranch (block);
205203
206- // Fill out wtx so that a transaction record can be created
207- wtx.nTimeReceived = nTimeReceived;
208- pwalletMain->AddToWallet (wtx);
204+ // Fill out wtx so that a transaction record can be created
205+ wtx.nTimeReceived = pindex->GetBlockTime ();
206+ pwalletMain->AddToWallet (wtx);
207+ setAddedTx.insert (txHash);
208+ }
209209
210- SetMintSeen (bnValue, nHeight, txHash, denomination);
210+ SetMintSeen (bnValue, pindex-> nHeight , txHash, denomination);
211211 nLastCountUsed = std::max (pMint.second , nLastCountUsed);
212212 nCountLastUsed = std::max (nLastCountUsed, nCountLastUsed);
213213 LogPrint (" zero" , " %s: updated count to %d\n " , __func__, nCountLastUsed);
0 commit comments