- 565FAF3EF371F5E2178AE30C45B08B93415EEB92263486E68F2AC2E8F4C7900056E628804BF5C0707A90BE946E0AEAEBFCD0A391AAB40DE2E5D56E6BCBDCCB1E
+ 93E1C42F397A6996DC73FB5CA1A13F1EC36F2E129782C97E0E45FF3058C943660A04D660DFC94DB01A6240C6C6B622A32E4CA57FA78EC580FC1065DCE4DC2579
bitcoin/src/db.cpp
(40 . 7)(40 . 7)
50 }
51 catch (const DbException& e)
52 {
53 printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno());
54 printf(SWAR SPRC "shutdown exception: %s (%d)\n", e.what(), e.get_errno());
55 }
56 DbEnv(0).remove(GetDataDir().c_str(), 0);
57 }
(81 . 7)(81 . 8)
59 string strLogDir = strDataDir + "/database";
60 filesystem::create_directory(strLogDir.c_str());
61 string strErrorFile = strDataDir + "/db.log";
62 printf("dbenv.open strLogDir=%s strErrorFile=%s\n", strLogDir.c_str(), strErrorFile.c_str());
63 printf(SINF SBLK "using database directory: %s\n", strLogDir.c_str());
64 printf(SINF SBLK "using database log: %s\n", strErrorFile.c_str());
65
66 dbenv.set_lg_dir(strLogDir.c_str());
67 dbenv.set_lg_max(1000000);
(196 . 7)(197 . 7)
69 mapFileUseCount.erase(strFile);
70
71 bool fSuccess = true;
72 printf("Rewriting %s...\n", strFile.c_str());
73 printf(SWAR SBLK "rewriting database file %s\n", strFile.c_str());
74 string strFileRes = strFile + ".rewrite";
75 { // surround usage of db with extra {}
76 CDB db(strFile.c_str(), "r");
(210 . 7)(211 . 7)
78 0);
79 if (ret > 0)
80 {
81 printf("Cannot create database file %s\n", strFileRes.c_str());
82 printf(SERR SBLK "can't create database file %s\n", strFileRes.c_str());
83 fSuccess = false;
84 }
85
(266 . 7)(267 . 7)
87 fSuccess = false;
88 }
89 if (!fSuccess)
90 printf("Rewriting of %s FAILED!\n", strFileRes.c_str());
91 printf(SERR SBLK "rewriting of database file %s\n", strFileRes.c_str());
92 return fSuccess;
93 }
94 }
(280 . 7)(281 . 7)
96 {
97 // Flush log data to the actual data file
98 // on all files that are not in use
99 printf("DBFlush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
100 printf(SINF SBLK "flushing log data. %s\n", fShutdown ? "shutting down" : "");
101 if (!fDbEnvInit)
102 return;
103 CRITICAL_BLOCK(cs_db)
(290 . 13)(291 . 13)
105 {
106 string strFile = (*mi).first;
107 int nRefCount = (*mi).second;
108 printf("%s refcount=%d\n", strFile.c_str(), nRefCount);
109 printf(SINF SBLK "database file %s has refcount %d\n", strFile.c_str(), nRefCount);
110 if (nRefCount == 0)
111 {
112 // Move log data to the dat file
113 CloseDb(strFile);
114 dbenv.txn_checkpoint(0, 0, 0);
115 printf("%s flush\n", strFile.c_str());
116 printf(SINF SBLK "flushing database file %s\n", strFile.c_str());
117 dbenv.lsn_reset(strFile.c_str(), 0);
118 mapFileUseCount.erase(mi++);
119 }
(540 . 7)(541 . 7)
121 pindexGenesisBlock = pindexNew;
122
123 if (!pindexNew->CheckIndex())
124 return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight);
125 return error(SBLK "block index check failed at height %d", pindexNew->nHeight);
126 }
127 else
128 {
(569 . 14)(570 . 14)
130 {
131 if (pindexGenesisBlock == NULL)
132 return true;
133 return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded");
134 return error(SBLK "chain tip loading failed");
135 }
136 if (!mapBlockIndex.count(hashBestChain))
137 return error("CTxDB::LoadBlockIndex() : hashBestChain not found in the block index");
138 return error(SBLK "chain tip %s not found in the block index", hashBestChain.ToString().c_str());
139 pindexBest = mapBlockIndex[hashBestChain];
140 nBestHeight = pindexBest->nHeight;
141 bnBestChainWork = pindexBest->bnChainWork;
142 printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight);
143 printf(SINF SBLK "chain tip %s at height %d\n", hashBestChain.ToString().c_str(), nBestHeight);
144
145 // Load bnBestInvalidWork, OK if it doesn't exist
146 ReadBestInvalidWork(bnBestInvalidWork);
(589 . 20)(590 . 22)
148 break;
149 CBlock block;
150 if (!block.ReadFromDisk(pindex))
151 return error("LoadBlockIndex() : block.ReadFromDisk failed");
152 return error(SBLK "block loading from disk failed");
153 if (!block.CheckBlock())
154 {
155 printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
156 printf(SWAR SBLK "found bad block %s at height %d\n",
157 pindex->GetBlockHash().ToString().c_str(), pindex->nHeight);
158 pindexFork = pindex->pprev;
159 }
160 }
161 if (pindexFork)
162 {
163 // Reorg back to the fork
164 printf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight);
165 printf(SINF SBLK "setting best chain pointer to block %s at height %d\n",
166 pindexFork->GetBlockHash().ToString().c_str(), pindexFork->nHeight);
167 CBlock block;
168 if (!block.ReadFromDisk(pindexFork))
169 return error("LoadBlockIndex() : block.ReadFromDisk failed");
170 return error(SBLK "block loading from disk failed");
171 CTxDB txdb;
172 block.SetBestChain(txdb, pindexFork);
173 }
(660 . 7)(663 . 7)
175 }
176 pcursor->close();
177
178 printf("Loaded %d addresses\n", mapAddresses.size());
179 printf(SINF SADR "loaded %d addresses\n", mapAddresses.size());
180 }
181
182 return true;
(814 . 7)(817 . 7)
184 wtx.pwallet = pwallet;
185
186 if (wtx.GetHash() != hash)
187 printf("Error in wallet.dat, hash mismatch\n");
188 printf(SERR SWAL "hash mismatch in wallet.dat\n");
189
190 // Undo serialize changes in 31600
191 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
(824 . 12)(827 . 12)
193 char fTmp;
194 char fUnused;
195 ssValue >> fTmp >> fUnused >> wtx.strFromAccount;
196 printf("LoadWallet() upgrading tx ver=%d %d '%s' %s\n", wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount.c_str(), hash.ToString().c_str());
197 printf(SINF SWAL "upgrading tx version to %d\n", wtx.fTimeReceivedIsTxTime);
198 wtx.fTimeReceivedIsTxTime = fTmp;
199 }
200 else
201 {
202 printf("LoadWallet() repairing tx ver=%d %s\n", wtx.fTimeReceivedIsTxTime, hash.ToString().c_str());
203 printf(SWAR SWAL "repairing tx version %d\n", wtx.fTimeReceivedIsTxTime);
204 wtx.fTimeReceivedIsTxTime = 0;
205 }
206 vWalletUpgrade.push_back(hash);
(943 . 13)(946 . 15)
208 BOOST_FOREACH(uint256 hash, vWalletUpgrade)
209 WriteTx(hash, pwallet->mapWallet[hash]);
210
211 printf("nFileVersion = %d\n", nFileVersion);
212 printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
213 printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
214 printf("fMinimizeToTray = %d\n", fMinimizeToTray);
215 printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
216 printf("fUseProxy = %d\n", fUseProxy);
217 printf("addrProxy = %s\n", addrProxy.ToString().c_str());
218 printf(SINF SWAL "file version is %d\n", nFileVersion);
219
220 if (fGenerateBitcoins)
221 printf(SINF SMIN "miner was activated\n");
222
223 printf(SINF SMEM "transaction fee is %"PRI64d"\n", nTransactionFee);
224
225 if (fUseProxy)
226 printf(SINF SNET "connecting through proxy on address %s\n", addrProxy.ToString().c_str());
227
228 // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
229 if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000))
(1008 . 8)(1013 . 7)
231 map<string, int>::iterator mi = mapFileUseCount.find(strFile);
232 if (mi != mapFileUseCount.end())
233 {
234 printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
235 printf("Flushing wallet.dat\n");
236 printf(SWAR SWAL "flushing wallet.dat\n");
237 nLastFlushed = nWalletDBUpdated;
238 int64 nStart = GetTimeMillis();
239
(1019 . 7)(1023 . 7)
241 dbenv.lsn_reset(strFile.c_str(), 0);
242
243 mapFileUseCount.erase(mi++);
244 printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
245 printf(SWAR SWAL "flushed wallet.dat in %"PRI64d"ms\n", GetTimeMillis() - nStart);
246 }
247 }
248 }
(1053 . 7)(1057 . 7)
250 #else
251 filesystem::copy_file(pathSrc, pathDest);
252 #endif
253 printf("copied wallet.dat to %s\n", pathDest.string().c_str());
254 printf(SINF SWAL "copied wallet.dat to %s\n", pathDest.string().c_str());
255
256 return true;
257 }