@@ -251,82 +251,6 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
251251 pcursor->close ();
252252}
253253
254- DBErrors CWalletDB::ReorderTransactions (CWallet* pwallet)
255- {
256- LOCK (pwallet->cs_wallet );
257- // Old wallets didn't have any defined order for transactions
258- // Probably a bad idea to change the output of this
259-
260- // First: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap.
261- typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
262- typedef multimap<int64_t , TxPair > TxItems;
263- TxItems txByTime;
264-
265- for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet .begin (); it != pwallet->mapWallet .end (); ++it)
266- {
267- CWalletTx* wtx = &((*it).second );
268- txByTime.insert (make_pair (wtx->nTimeReceived , TxPair (wtx, (CAccountingEntry*)0 )));
269- }
270- list<CAccountingEntry> acentries;
271- ListAccountCreditDebit (" " , acentries);
272- BOOST_FOREACH (CAccountingEntry& entry, acentries)
273- {
274- txByTime.insert (make_pair (entry.nTime , TxPair ((CWalletTx*)0 , &entry)));
275- }
276-
277- int64_t & nOrderPosNext = pwallet->nOrderPosNext ;
278- nOrderPosNext = 0 ;
279- std::vector<int64_t > nOrderPosOffsets;
280- for (TxItems::iterator it = txByTime.begin (); it != txByTime.end (); ++it)
281- {
282- CWalletTx *const pwtx = (*it).second .first ;
283- CAccountingEntry *const pacentry = (*it).second .second ;
284- int64_t & nOrderPos = (pwtx != 0 ) ? pwtx->nOrderPos : pacentry->nOrderPos ;
285-
286- if (nOrderPos == -1 )
287- {
288- nOrderPos = nOrderPosNext++;
289- nOrderPosOffsets.push_back (nOrderPos);
290-
291- if (pwtx)
292- {
293- if (!WriteTx (*pwtx))
294- return DB_LOAD_FAIL;
295- }
296- else
297- if (!WriteAccountingEntry (pacentry->nEntryNo , *pacentry))
298- return DB_LOAD_FAIL;
299- }
300- else
301- {
302- int64_t nOrderPosOff = 0 ;
303- BOOST_FOREACH (const int64_t & nOffsetStart, nOrderPosOffsets)
304- {
305- if (nOrderPos >= nOffsetStart)
306- ++nOrderPosOff;
307- }
308- nOrderPos += nOrderPosOff;
309- nOrderPosNext = std::max (nOrderPosNext, nOrderPos + 1 );
310-
311- if (!nOrderPosOff)
312- continue ;
313-
314- // Since we're changing the order, write it back
315- if (pwtx)
316- {
317- if (!WriteTx (*pwtx))
318- return DB_LOAD_FAIL;
319- }
320- else
321- if (!WriteAccountingEntry (pacentry->nEntryNo , *pacentry))
322- return DB_LOAD_FAIL;
323- }
324- }
325- WriteOrderPosNext (nOrderPosNext);
326-
327- return DB_LOAD_OK;
328- }
329-
330254class CWalletScanState {
331255public:
332256 unsigned int nKeys;
@@ -711,7 +635,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
711635 WriteVersion (CLIENT_VERSION);
712636
713637 if (wss.fAnyUnordered )
714- result = ReorderTransactions (pwallet );
638+ result = pwallet-> ReorderTransactions ();
715639
716640 pwallet->laccentries .clear ();
717641 ListAccountCreditDebit (" *" , pwallet->laccentries );
0 commit comments