Mercurial > hg > bitcoin
annotate src/db.cpp @ 1505:d54fc7452031 draft
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
author | Gavin Andresen <gavinandresen@gmail.com> |
---|---|
date | Tue, 15 Nov 2011 14:30:15 -0500 |
parents | 17ffa7828615 |
children | dbb47cc56537 |
rev | line source |
---|---|
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1 // Copyright (c) 2009-2010 Satoshi Nakamoto |
846 | 2 // Copyright (c) 2011 The Bitcoin developers |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
3 // Distributed under the MIT/X11 software license, see the accompanying |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
4 // file license.txt or http://www.opensource.org/licenses/mit-license.php. |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
5 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
6 #include "headers.h" |
605
1ae81ad9b0e5
Only include db.h when we have to.
Jordan Lewis <jordanthelewis@gmail.com>
parents:
595
diff
changeset
|
7 #include "db.h" |
607
92e329774c81
Only include net.h when we have to
Jordan Lewis <jordanthelewis@gmail.com>
parents:
605
diff
changeset
|
8 #include "net.h" |
695
9609c7af94ba
Fix missing includes needed for Boost 1.46.
Shane Wegner <shane-github@csy.ca>
parents:
690
diff
changeset
|
9 #include <boost/filesystem.hpp> |
611
503d51554676
Only include certain boost headers if necessary.
Jordan Lewis <jordanthelewis@gmail.com>
parents:
607
diff
changeset
|
10 #include <boost/filesystem/fstream.hpp> |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
11 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
576
diff
changeset
|
12 using namespace std; |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
576
diff
changeset
|
13 using namespace boost; |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
576
diff
changeset
|
14 |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
15 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
16 unsigned int nWalletDBUpdated; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
17 uint64 nAccountingEntryNumber = 0; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
18 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
19 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
20 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
21 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
22 // CDB |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
23 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
24 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
25 static CCriticalSection cs_db; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
26 static bool fDbEnvInit = false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
27 DbEnv dbenv(0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
28 static map<string, int> mapFileUseCount; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
29 static map<string, Db*> mapDb; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
30 |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
31 static void EnvShutdown(bool fRemoveLogFiles) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
32 { |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
33 if (!fDbEnvInit) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
34 return; |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
35 |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
36 fDbEnvInit = false; |
1505
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
37 try |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
38 { |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
39 dbenv.close(0); |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
40 } |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
41 catch (const DbException& e) |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
42 { |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
43 printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno()); |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
44 } |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
45 DbEnv(0).remove(GetDataDir().c_str(), 0); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
46 |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
47 if (fRemoveLogFiles) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
48 { |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
49 filesystem::path datadir(GetDataDir()); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
50 filesystem::directory_iterator it(datadir / "database"); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
51 while (it != filesystem::directory_iterator()) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
52 { |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
53 const filesystem::path& p = it->path(); |
1504
17ffa7828615
Fix boost filesystem incompatibility problem
Gavin Andresen <gavinandresen@gmail.com>
parents:
1501
diff
changeset
|
54 #if BOOST_FILESYSTEM_VERSION == 3 |
17ffa7828615
Fix boost filesystem incompatibility problem
Gavin Andresen <gavinandresen@gmail.com>
parents:
1501
diff
changeset
|
55 std::string f = p.filename().generic_string(); |
17ffa7828615
Fix boost filesystem incompatibility problem
Gavin Andresen <gavinandresen@gmail.com>
parents:
1501
diff
changeset
|
56 #else |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
57 std::string f = p.filename(); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
58 #endif |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
59 if (f.find("log.") == 0) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
60 filesystem::remove(p); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
61 ++it; |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
62 } |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
63 } |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
64 } |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
65 |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
66 class CDBInit |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
67 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
68 public: |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
69 CDBInit() |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
70 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
71 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
72 ~CDBInit() |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
73 { |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
74 EnvShutdown(false); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
75 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
76 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
77 instance_of_cdbinit; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
78 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
79 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
80 CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
81 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
82 int ret; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
83 if (pszFile == NULL) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
84 return; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
85 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
86 fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w')); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
87 bool fCreate = strchr(pszMode, 'c'); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
88 unsigned int nFlags = DB_THREAD; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
89 if (fCreate) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
90 nFlags |= DB_CREATE; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
91 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
92 CRITICAL_BLOCK(cs_db) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
93 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
94 if (!fDbEnvInit) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
95 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
96 if (fShutdown) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
97 return; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
98 string strDataDir = GetDataDir(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
99 string strLogDir = strDataDir + "/database"; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
100 filesystem::create_directory(strLogDir.c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
101 string strErrorFile = strDataDir + "/db.log"; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
102 printf("dbenv.open strLogDir=%s strErrorFile=%s\n", strLogDir.c_str(), strErrorFile.c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
103 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
104 dbenv.set_lg_dir(strLogDir.c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
105 dbenv.set_lg_max(10000000); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
106 dbenv.set_lk_max_locks(10000); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
107 dbenv.set_lk_max_objects(10000); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
108 dbenv.set_errfile(fopen(strErrorFile.c_str(), "a")); /// debug |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
109 dbenv.set_flags(DB_AUTO_COMMIT, 1); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
110 ret = dbenv.open(strDataDir.c_str(), |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
111 DB_CREATE | |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
112 DB_INIT_LOCK | |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
113 DB_INIT_LOG | |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
114 DB_INIT_MPOOL | |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
115 DB_INIT_TXN | |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
116 DB_THREAD | |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
117 DB_RECOVER, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
118 S_IRUSR | S_IWUSR); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
119 if (ret > 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
120 throw runtime_error(strprintf("CDB() : error %d opening database environment", ret)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
121 fDbEnvInit = true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
122 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
123 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
124 strFile = pszFile; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
125 ++mapFileUseCount[strFile]; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
126 pdb = mapDb[strFile]; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
127 if (pdb == NULL) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
128 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
129 pdb = new Db(&dbenv, 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
130 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
131 ret = pdb->open(NULL, // Txn pointer |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
132 pszFile, // Filename |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
133 "main", // Logical db name |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
134 DB_BTREE, // Database type |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
135 nFlags, // Flags |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
136 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
137 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
138 if (ret > 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
139 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
140 delete pdb; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
141 pdb = NULL; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
142 CRITICAL_BLOCK(cs_db) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
143 --mapFileUseCount[strFile]; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
144 strFile = ""; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
145 throw runtime_error(strprintf("CDB() : can't open database file %s, error %d", pszFile, ret)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
146 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
147 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
148 if (fCreate && !Exists(string("version"))) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
149 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
150 bool fTmp = fReadOnly; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
151 fReadOnly = false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
152 WriteVersion(VERSION); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
153 fReadOnly = fTmp; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
154 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
155 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
156 mapDb[strFile] = pdb; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
157 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
158 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
159 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
160 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
161 void CDB::Close() |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
162 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
163 if (!pdb) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
164 return; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
165 if (!vTxn.empty()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
166 vTxn.front()->abort(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
167 vTxn.clear(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
168 pdb = NULL; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
169 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
170 // Flush database activity from memory pool to disk log |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
171 unsigned int nMinutes = 0; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
172 if (fReadOnly) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
173 nMinutes = 1; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
174 if (strFile == "addr.dat") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
175 nMinutes = 2; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
176 if (strFile == "blkindex.dat" && IsInitialBlockDownload() && nBestHeight % 500 != 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
177 nMinutes = 1; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
178 dbenv.txn_checkpoint(0, nMinutes, 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
179 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
180 CRITICAL_BLOCK(cs_db) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
181 --mapFileUseCount[strFile]; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
182 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
183 |
690 | 184 void static CloseDb(const string& strFile) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
185 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
186 CRITICAL_BLOCK(cs_db) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
187 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
188 if (mapDb[strFile] != NULL) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
189 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
190 // Close the database handle |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
191 Db* pdb = mapDb[strFile]; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
192 pdb->close(0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
193 delete pdb; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
194 mapDb[strFile] = NULL; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
195 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
196 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
197 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
198 |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
199 bool CDB::Rewrite(const string& strFile, const char* pszSkip) |
1500 | 200 { |
201 while (!fShutdown) | |
202 { | |
203 CRITICAL_BLOCK(cs_db) | |
204 { | |
205 if (!mapFileUseCount.count(strFile) || mapFileUseCount[strFile] == 0) | |
206 { | |
207 // Flush log data to the dat file | |
208 CloseDb(strFile); | |
209 dbenv.txn_checkpoint(0, 0, 0); | |
210 dbenv.lsn_reset(strFile.c_str(), 0); | |
211 mapFileUseCount.erase(strFile); | |
212 | |
213 bool fSuccess = true; | |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
214 printf("Rewriting %s...\n", strFile.c_str()); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
215 string strFileRes = strFile + ".rewrite"; |
1500 | 216 CDB db(strFile.c_str(), "r"); |
217 Db* pdbCopy = new Db(&dbenv, 0); | |
218 | |
219 int ret = pdbCopy->open(NULL, // Txn pointer | |
220 strFileRes.c_str(), // Filename | |
221 "main", // Logical db name | |
222 DB_BTREE, // Database type | |
223 DB_CREATE, // Flags | |
224 0); | |
225 if (ret > 0) | |
226 { | |
227 printf("Cannot create database file %s\n", strFileRes.c_str()); | |
228 fSuccess = false; | |
229 } | |
230 | |
231 Dbc* pcursor = db.GetCursor(); | |
232 if (pcursor) | |
233 while (fSuccess) | |
234 { | |
235 CDataStream ssKey; | |
236 CDataStream ssValue; | |
237 int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); | |
238 if (ret == DB_NOTFOUND) | |
1505
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
239 { |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
240 pcursor->close(); |
1500 | 241 break; |
1505
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
242 } |
1500 | 243 else if (ret != 0) |
244 { | |
245 pcursor->close(); | |
246 fSuccess = false; | |
247 break; | |
248 } | |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
249 if (pszSkip && |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
250 strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
251 continue; |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
252 if (strncmp(&ssKey[0], "\x07version", 8) == 0) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
253 { |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
254 // Update version: |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
255 ssValue.clear(); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
256 ssValue << VERSION; |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
257 } |
1500 | 258 Dbt datKey(&ssKey[0], ssKey.size()); |
259 Dbt datValue(&ssValue[0], ssValue.size()); | |
260 int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); | |
261 if (ret2 > 0) | |
262 fSuccess = false; | |
263 } | |
264 if (fSuccess) | |
265 { | |
1505
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
266 db.Close(); |
d54fc7452031
Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1504
diff
changeset
|
267 CloseDb(strFile); |
1500 | 268 if (pdbCopy->close(0)) |
269 fSuccess = false; | |
270 delete pdbCopy; | |
271 } | |
272 if (fSuccess) | |
273 { | |
274 Db dbA(&dbenv, 0); | |
275 if (dbA.remove(strFile.c_str(), NULL, 0)) | |
276 fSuccess = false; | |
277 Db dbB(&dbenv, 0); | |
278 if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0)) | |
279 fSuccess = false; | |
280 } | |
281 if (!fSuccess) | |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
282 printf("Rewriting of %s FAILED!\n", strFileRes.c_str()); |
1500 | 283 return fSuccess; |
284 } | |
285 } | |
286 Sleep(100); | |
287 } | |
288 return false; | |
289 } | |
290 | |
291 | |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
292 void DBFlush(bool fShutdown, bool fRemoveLogFiles) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
293 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
294 // Flush log data to the actual data file |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
295 // on all files that are not in use |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
296 printf("DBFlush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
297 if (!fDbEnvInit) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
298 return; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
299 CRITICAL_BLOCK(cs_db) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
300 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
301 map<string, int>::iterator mi = mapFileUseCount.begin(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
302 while (mi != mapFileUseCount.end()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
303 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
304 string strFile = (*mi).first; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
305 int nRefCount = (*mi).second; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
306 printf("%s refcount=%d\n", strFile.c_str(), nRefCount); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
307 if (nRefCount == 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
308 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
309 // Move log data to the dat file |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
310 CloseDb(strFile); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
311 dbenv.txn_checkpoint(0, 0, 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
312 printf("%s flush\n", strFile.c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
313 dbenv.lsn_reset(strFile.c_str(), 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
314 mapFileUseCount.erase(mi++); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
315 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
316 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
317 mi++; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
318 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
319 if (fShutdown) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
320 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
321 char** listp; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
322 if (mapFileUseCount.empty()) |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
323 { |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
324 dbenv.log_archive(&listp, DB_ARCH_REMOVE); |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
325 EnvShutdown(fRemoveLogFiles); |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
326 } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
327 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
328 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
329 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
330 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
331 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
332 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
333 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
334 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
335 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
336 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
337 // CTxDB |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
338 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
339 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
340 bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
341 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
342 assert(!fClient); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
343 txindex.SetNull(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
344 return Read(make_pair(string("tx"), hash), txindex); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
345 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
346 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
347 bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
348 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
349 assert(!fClient); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
350 return Write(make_pair(string("tx"), hash), txindex); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
351 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
352 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
353 bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
354 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
355 assert(!fClient); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
356 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
357 // Add to tx index |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
358 uint256 hash = tx.GetHash(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
359 CTxIndex txindex(pos, tx.vout.size()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
360 return Write(make_pair(string("tx"), hash), txindex); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
361 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
362 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
363 bool CTxDB::EraseTxIndex(const CTransaction& tx) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
364 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
365 assert(!fClient); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
366 uint256 hash = tx.GetHash(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
367 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
368 return Erase(make_pair(string("tx"), hash)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
369 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
370 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
371 bool CTxDB::ContainsTx(uint256 hash) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
372 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
373 assert(!fClient); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
374 return Exists(make_pair(string("tx"), hash)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
375 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
376 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
377 bool CTxDB::ReadOwnerTxes(uint160 hash160, int nMinHeight, vector<CTransaction>& vtx) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
378 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
379 assert(!fClient); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
380 vtx.clear(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
381 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
382 // Get cursor |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
383 Dbc* pcursor = GetCursor(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
384 if (!pcursor) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
385 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
386 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
387 unsigned int fFlags = DB_SET_RANGE; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
388 loop |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
389 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
390 // Read next record |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
391 CDataStream ssKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
392 if (fFlags == DB_SET_RANGE) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
393 ssKey << string("owner") << hash160 << CDiskTxPos(0, 0, 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
394 CDataStream ssValue; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
395 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
396 fFlags = DB_NEXT; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
397 if (ret == DB_NOTFOUND) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
398 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
399 else if (ret != 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
400 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
401 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
402 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
403 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
404 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
405 // Unserialize |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
406 string strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
407 uint160 hashItem; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
408 CDiskTxPos pos; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
409 ssKey >> strType >> hashItem >> pos; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
410 int nItemHeight; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
411 ssValue >> nItemHeight; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
412 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
413 // Read transaction |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
414 if (strType != "owner" || hashItem != hash160) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
415 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
416 if (nItemHeight >= nMinHeight) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
417 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
418 vtx.resize(vtx.size()+1); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
419 if (!vtx.back().ReadFromDisk(pos)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
420 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
421 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
422 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
423 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
424 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
425 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
426 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
427 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
428 return true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
429 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
430 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
431 bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
432 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
433 assert(!fClient); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
434 tx.SetNull(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
435 if (!ReadTxIndex(hash, txindex)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
436 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
437 return (tx.ReadFromDisk(txindex.pos)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
438 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
439 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
440 bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
441 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
442 CTxIndex txindex; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
443 return ReadDiskTx(hash, tx, txindex); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
444 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
445 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
446 bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
447 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
448 return ReadDiskTx(outpoint.hash, tx, txindex); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
449 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
450 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
451 bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
452 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
453 CTxIndex txindex; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
454 return ReadDiskTx(outpoint.hash, tx, txindex); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
455 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
456 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
457 bool CTxDB::WriteBlockIndex(const CDiskBlockIndex& blockindex) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
458 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
459 return Write(make_pair(string("blockindex"), blockindex.GetBlockHash()), blockindex); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
460 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
461 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
462 bool CTxDB::EraseBlockIndex(uint256 hash) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
463 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
464 return Erase(make_pair(string("blockindex"), hash)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
465 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
466 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
467 bool CTxDB::ReadHashBestChain(uint256& hashBestChain) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
468 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
469 return Read(string("hashBestChain"), hashBestChain); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
470 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
471 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
472 bool CTxDB::WriteHashBestChain(uint256 hashBestChain) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
473 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
474 return Write(string("hashBestChain"), hashBestChain); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
475 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
476 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
477 bool CTxDB::ReadBestInvalidWork(CBigNum& bnBestInvalidWork) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
478 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
479 return Read(string("bnBestInvalidWork"), bnBestInvalidWork); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
480 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
481 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
482 bool CTxDB::WriteBestInvalidWork(CBigNum bnBestInvalidWork) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
483 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
484 return Write(string("bnBestInvalidWork"), bnBestInvalidWork); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
485 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
486 |
690 | 487 CBlockIndex static * InsertBlockIndex(uint256 hash) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
488 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
489 if (hash == 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
490 return NULL; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
491 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
492 // Return existing |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
493 map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
494 if (mi != mapBlockIndex.end()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
495 return (*mi).second; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
496 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
497 // Create new |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
498 CBlockIndex* pindexNew = new CBlockIndex(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
499 if (!pindexNew) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
500 throw runtime_error("LoadBlockIndex() : new CBlockIndex failed"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
501 mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
502 pindexNew->phashBlock = &((*mi).first); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
503 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
504 return pindexNew; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
505 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
506 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
507 bool CTxDB::LoadBlockIndex() |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
508 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
509 // Get database cursor |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
510 Dbc* pcursor = GetCursor(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
511 if (!pcursor) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
512 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
513 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
514 // Load mapBlockIndex |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
515 unsigned int fFlags = DB_SET_RANGE; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
516 loop |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
517 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
518 // Read next record |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
519 CDataStream ssKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
520 if (fFlags == DB_SET_RANGE) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
521 ssKey << make_pair(string("blockindex"), uint256(0)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
522 CDataStream ssValue; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
523 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
524 fFlags = DB_NEXT; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
525 if (ret == DB_NOTFOUND) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
526 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
527 else if (ret != 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
528 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
529 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
530 // Unserialize |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
531 string strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
532 ssKey >> strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
533 if (strType == "blockindex") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
534 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
535 CDiskBlockIndex diskindex; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
536 ssValue >> diskindex; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
537 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
538 // Construct block index object |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
539 CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
540 pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
541 pindexNew->pnext = InsertBlockIndex(diskindex.hashNext); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
542 pindexNew->nFile = diskindex.nFile; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
543 pindexNew->nBlockPos = diskindex.nBlockPos; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
544 pindexNew->nHeight = diskindex.nHeight; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
545 pindexNew->nVersion = diskindex.nVersion; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
546 pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
547 pindexNew->nTime = diskindex.nTime; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
548 pindexNew->nBits = diskindex.nBits; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
549 pindexNew->nNonce = diskindex.nNonce; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
550 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
551 // Watch for genesis block |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
552 if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == hashGenesisBlock) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
553 pindexGenesisBlock = pindexNew; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
554 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
555 if (!pindexNew->CheckIndex()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
556 return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
557 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
558 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
559 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
560 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
561 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
562 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
563 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
564 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
565 // Calculate bnChainWork |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
566 vector<pair<int, CBlockIndex*> > vSortedByHeight; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
567 vSortedByHeight.reserve(mapBlockIndex.size()); |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
576
diff
changeset
|
568 BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
569 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
570 CBlockIndex* pindex = item.second; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
571 vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
572 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
573 sort(vSortedByHeight.begin(), vSortedByHeight.end()); |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
576
diff
changeset
|
574 BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
575 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
576 CBlockIndex* pindex = item.second; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
577 pindex->bnChainWork = (pindex->pprev ? pindex->pprev->bnChainWork : 0) + pindex->GetBlockWork(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
578 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
579 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
580 // Load hashBestChain pointer to end of best chain |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
581 if (!ReadHashBestChain(hashBestChain)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
582 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
583 if (pindexGenesisBlock == NULL) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
584 return true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
585 return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
586 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
587 if (!mapBlockIndex.count(hashBestChain)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
588 return error("CTxDB::LoadBlockIndex() : hashBestChain not found in the block index"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
589 pindexBest = mapBlockIndex[hashBestChain]; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
590 nBestHeight = pindexBest->nHeight; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
591 bnBestChainWork = pindexBest->bnChainWork; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
592 printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
593 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
594 // Load bnBestInvalidWork, OK if it doesn't exist |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
595 ReadBestInvalidWork(bnBestInvalidWork); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
596 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
597 // Verify blocks in the best chain |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
598 CBlockIndex* pindexFork = NULL; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
599 for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
600 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
601 if (pindex->nHeight < nBestHeight-2500 && !mapArgs.count("-checkblocks")) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
602 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
603 CBlock block; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
604 if (!block.ReadFromDisk(pindex)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
605 return error("LoadBlockIndex() : block.ReadFromDisk failed"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
606 if (!block.CheckBlock()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
607 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
608 printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
609 pindexFork = pindex->pprev; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
610 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
611 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
612 if (pindexFork) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
613 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
614 // Reorg back to the fork |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
615 printf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
616 CBlock block; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
617 if (!block.ReadFromDisk(pindexFork)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
618 return error("LoadBlockIndex() : block.ReadFromDisk failed"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
619 CTxDB txdb; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
620 block.SetBestChain(txdb, pindexFork); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
621 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
622 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
623 return true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
624 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
625 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
626 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
627 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
628 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
629 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
630 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
631 // CAddrDB |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
632 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
633 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
634 bool CAddrDB::WriteAddress(const CAddress& addr) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
635 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
636 return Write(make_pair(string("addr"), addr.GetKey()), addr); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
637 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
638 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
639 bool CAddrDB::EraseAddress(const CAddress& addr) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
640 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
641 return Erase(make_pair(string("addr"), addr.GetKey())); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
642 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
643 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
644 bool CAddrDB::LoadAddresses() |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
645 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
646 CRITICAL_BLOCK(cs_mapAddresses) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
647 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
648 // Get cursor |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
649 Dbc* pcursor = GetCursor(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
650 if (!pcursor) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
651 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
652 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
653 loop |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
654 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
655 // Read next record |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
656 CDataStream ssKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
657 CDataStream ssValue; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
658 int ret = ReadAtCursor(pcursor, ssKey, ssValue); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
659 if (ret == DB_NOTFOUND) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
660 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
661 else if (ret != 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
662 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
663 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
664 // Unserialize |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
665 string strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
666 ssKey >> strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
667 if (strType == "addr") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
668 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
669 CAddress addr; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
670 ssValue >> addr; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
671 mapAddresses.insert(make_pair(addr.GetKey(), addr)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
672 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
673 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
674 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
675 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
676 printf("Loaded %d addresses\n", mapAddresses.size()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
677 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
678 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
679 return true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
680 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
681 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
682 bool LoadAddresses() |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
683 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
684 return CAddrDB("cr+").LoadAddresses(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
685 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
686 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
687 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
688 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
689 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
690 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
691 // CWalletDB |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
692 // |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
693 |
690 | 694 bool CWalletDB::WriteName(const string& strAddress, const string& strName) |
695 { | |
696 nWalletDBUpdated++; | |
697 return Write(make_pair(string("name"), strAddress), strName); | |
698 } | |
699 | |
700 bool CWalletDB::EraseName(const string& strAddress) | |
701 { | |
702 // This should only be used for sending addresses, never for receiving addresses, | |
703 // receiving addresses must always have an address book entry if they're not change return. | |
704 nWalletDBUpdated++; | |
705 return Erase(make_pair(string("name"), strAddress)); | |
706 } | |
707 | |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
708 bool CWalletDB::ReadAccount(const string& strAccount, CAccount& account) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
709 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
710 account.SetNull(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
711 return Read(make_pair(string("acc"), strAccount), account); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
712 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
713 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
714 bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
715 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
716 return Write(make_pair(string("acc"), strAccount), account); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
717 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
718 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
719 bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
720 { |
847
b0c5cacbefd1
Qualify make_tuple with boost:: namespace.
Venkatesh Srinivas <me@endeavour.zapto.org>
parents:
829
diff
changeset
|
721 return Write(boost::make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
722 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
723 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
724 int64 CWalletDB::GetAccountCreditDebit(const string& strAccount) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
725 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
726 list<CAccountingEntry> entries; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
727 ListAccountCreditDebit(strAccount, entries); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
728 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
729 int64 nCreditDebit = 0; |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
576
diff
changeset
|
730 BOOST_FOREACH (const CAccountingEntry& entry, entries) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
731 nCreditDebit += entry.nCreditDebit; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
732 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
733 return nCreditDebit; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
734 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
735 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
736 void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
737 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
738 bool fAllAccounts = (strAccount == "*"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
739 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
740 Dbc* pcursor = GetCursor(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
741 if (!pcursor) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
742 throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
743 unsigned int fFlags = DB_SET_RANGE; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
744 loop |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
745 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
746 // Read next record |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
747 CDataStream ssKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
748 if (fFlags == DB_SET_RANGE) |
847
b0c5cacbefd1
Qualify make_tuple with boost:: namespace.
Venkatesh Srinivas <me@endeavour.zapto.org>
parents:
829
diff
changeset
|
749 ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0)); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
750 CDataStream ssValue; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
751 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
752 fFlags = DB_NEXT; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
753 if (ret == DB_NOTFOUND) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
754 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
755 else if (ret != 0) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
756 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
757 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
758 throw runtime_error("CWalletDB::ListAccountCreditDebit() : error scanning DB"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
759 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
760 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
761 // Unserialize |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
762 string strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
763 ssKey >> strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
764 if (strType != "acentry") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
765 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
766 CAccountingEntry acentry; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
767 ssKey >> acentry.strAccount; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
768 if (!fAllAccounts && acentry.strAccount != strAccount) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
769 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
770 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
771 ssValue >> acentry; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
772 entries.push_back(acentry); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
773 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
774 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
775 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
776 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
777 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
778 |
746 | 779 int CWalletDB::LoadWallet(CWallet* pwallet) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
780 { |
690 | 781 pwallet->vchDefaultKey.clear(); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
782 int nFileVersion = 0; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
783 vector<uint256> vWalletUpgrade; |
1500 | 784 bool fIsEncrypted = false; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
785 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
786 // Modify defaults |
1390
97bac6569f62
Fix build on windows and mac
Gavin Andresen <gavinandresen@gmail.com>
parents:
1362
diff
changeset
|
787 #ifndef WIN32 |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
788 // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
789 fMinimizeToTray = false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
790 fMinimizeOnClose = false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
791 #endif |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
792 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
793 //// todo: shouldn't we catch exceptions and try to recover and continue? |
892
51e9fb5de117
Fix rpc-hanging deadlocks
Gavin Andresen <gavinandresen@gmail.com>
parents:
863
diff
changeset
|
794 CRITICAL_BLOCK(pwallet->cs_wallet) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
795 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
796 // Get cursor |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
797 Dbc* pcursor = GetCursor(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
798 if (!pcursor) |
746 | 799 return DB_CORRUPT; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
800 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
801 loop |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
802 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
803 // Read next record |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
804 CDataStream ssKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
805 CDataStream ssValue; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
806 int ret = ReadAtCursor(pcursor, ssKey, ssValue); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
807 if (ret == DB_NOTFOUND) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
808 break; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
809 else if (ret != 0) |
746 | 810 return DB_CORRUPT; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
811 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
812 // Unserialize |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
813 // Taking advantage of the fact that pair serialization |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
814 // is just the two items serialized one after the other |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
815 string strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
816 ssKey >> strType; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
817 if (strType == "name") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
818 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
819 string strAddress; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
820 ssKey >> strAddress; |
690 | 821 ssValue >> pwallet->mapAddressBook[strAddress]; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
822 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
823 else if (strType == "tx") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
824 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
825 uint256 hash; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
826 ssKey >> hash; |
690 | 827 CWalletTx& wtx = pwallet->mapWallet[hash]; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
828 ssValue >> wtx; |
690 | 829 wtx.pwallet = pwallet; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
830 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
831 if (wtx.GetHash() != hash) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
832 printf("Error in wallet.dat, hash mismatch\n"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
833 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
834 // Undo serialize changes in 31600 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
835 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
836 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
837 if (!ssValue.empty()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
838 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
839 char fTmp; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
840 char fUnused; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
841 ssValue >> fTmp >> fUnused >> wtx.strFromAccount; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
842 printf("LoadWallet() upgrading tx ver=%d %d '%s' %s\n", wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount.c_str(), hash.ToString().c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
843 wtx.fTimeReceivedIsTxTime = fTmp; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
844 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
845 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
846 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
847 printf("LoadWallet() repairing tx ver=%d %s\n", wtx.fTimeReceivedIsTxTime, hash.ToString().c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
848 wtx.fTimeReceivedIsTxTime = 0; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
849 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
850 vWalletUpgrade.push_back(hash); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
851 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
852 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
853 //// debug print |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
854 //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
855 //printf(" %12I64d %s %s %s\n", |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
856 // wtx.vout[0].nValue, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
857 // DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(), |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
858 // wtx.hashBlock.ToString().substr(0,20).c_str(), |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
859 // wtx.mapValue["message"].c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
860 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
861 else if (strType == "acentry") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
862 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
863 string strAccount; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
864 ssKey >> strAccount; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
865 uint64 nNumber; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
866 ssKey >> nNumber; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
867 if (nNumber > nAccountingEntryNumber) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
868 nAccountingEntryNumber = nNumber; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
869 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
870 else if (strType == "key" || strType == "wkey") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
871 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
872 vector<unsigned char> vchPubKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
873 ssKey >> vchPubKey; |
757
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
874 CKey key; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
875 if (strType == "key") |
757
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
876 { |
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
877 CPrivKey pkey; |
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
878 ssValue >> pkey; |
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
879 key.SetPrivKey(pkey); |
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
880 } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
881 else |
757
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
882 { |
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
883 CWalletKey wkey; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
884 ssValue >> wkey; |
757
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
885 key.SetPrivKey(wkey.vchPrivKey); |
ee9183806240
Prepare codebase for Encrypted Keys.
Pieter Wuille <pieter.wuille@gmail.com>
parents:
695
diff
changeset
|
886 } |
760
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
887 if (!pwallet->LoadKey(key)) |
802
4b444ebb854e
Fix bad return values in LoadWallet.
Matt Corallo <matt@bluematt.me>
parents:
780
diff
changeset
|
888 return DB_CORRUPT; |
760
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
889 } |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
890 else if (strType == "mkey") |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
891 { |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
892 unsigned int nID; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
893 ssKey >> nID; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
894 CMasterKey kMasterKey; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
895 ssValue >> kMasterKey; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
896 if(pwallet->mapMasterKeys.count(nID) != 0) |
802
4b444ebb854e
Fix bad return values in LoadWallet.
Matt Corallo <matt@bluematt.me>
parents:
780
diff
changeset
|
897 return DB_CORRUPT; |
760
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
898 pwallet->mapMasterKeys[nID] = kMasterKey; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
899 if (pwallet->nMasterKeyMaxID < nID) |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
900 pwallet->nMasterKeyMaxID = nID; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
901 } |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
902 else if (strType == "ckey") |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
903 { |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
904 vector<unsigned char> vchPubKey; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
905 ssKey >> vchPubKey; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
906 vector<unsigned char> vchPrivKey; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
907 ssValue >> vchPrivKey; |
fd7e5b1cfc08
Add wallet privkey encryption.
Matt Corallo <matt@bluematt.me>
parents:
757
diff
changeset
|
908 if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey)) |
802
4b444ebb854e
Fix bad return values in LoadWallet.
Matt Corallo <matt@bluematt.me>
parents:
780
diff
changeset
|
909 return DB_CORRUPT; |
1500 | 910 fIsEncrypted = true; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
911 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
912 else if (strType == "defaultkey") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
913 { |
690 | 914 ssValue >> pwallet->vchDefaultKey; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
915 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
916 else if (strType == "pool") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
917 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
918 int64 nIndex; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
919 ssKey >> nIndex; |
690 | 920 pwallet->setKeyPool.insert(nIndex); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
921 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
922 else if (strType == "version") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
923 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
924 ssValue >> nFileVersion; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
925 if (nFileVersion == 10300) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
926 nFileVersion = 300; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
927 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
928 else if (strType == "setting") |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
929 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
930 string strKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
931 ssKey >> strKey; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
932 |
576
8ec6d5e778e5
Manual merge of jaromil's source tree reorg commit.
Jeff Garzik <jeff@garzik.org>
parents:
575
diff
changeset
|
933 // Options |
1320 | 934 #ifndef QT_GUI |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
935 if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins; |
576
8ec6d5e778e5
Manual merge of jaromil's source tree reorg commit.
Jeff Garzik <jeff@garzik.org>
parents:
575
diff
changeset
|
936 #endif |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
937 if (strKey == "nTransactionFee") ssValue >> nTransactionFee; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
938 if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
939 if (strKey == "nLimitProcessors") ssValue >> nLimitProcessors; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
940 if (strKey == "fMinimizeToTray") ssValue >> fMinimizeToTray; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
941 if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
942 if (strKey == "fUseProxy") ssValue >> fUseProxy; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
943 if (strKey == "addrProxy") ssValue >> addrProxy; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
944 if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
945 } |
746 | 946 else if (strType == "minversion") |
947 { | |
948 int nMinVersion = 0; | |
949 ssValue >> nMinVersion; | |
950 if (nMinVersion > VERSION) | |
951 return DB_TOO_NEW; | |
952 } | |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
953 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
954 pcursor->close(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
955 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
956 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
576
diff
changeset
|
957 BOOST_FOREACH(uint256 hash, vWalletUpgrade) |
690 | 958 WriteTx(hash, pwallet->mapWallet[hash]); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
959 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
960 printf("nFileVersion = %d\n", nFileVersion); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
961 printf("fGenerateBitcoins = %d\n", fGenerateBitcoins); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
962 printf("nTransactionFee = %"PRI64d"\n", nTransactionFee); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
963 printf("fMinimizeToTray = %d\n", fMinimizeToTray); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
964 printf("fMinimizeOnClose = %d\n", fMinimizeOnClose); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
965 printf("fUseProxy = %d\n", fUseProxy); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
966 printf("addrProxy = %s\n", addrProxy.ToString().c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
967 if (fHaveUPnP) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
968 printf("fUseUPnP = %d\n", fUseUPnP); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
969 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
970 |
1501
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
971 // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
972 if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000)) |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
973 return DB_NEED_REWRITE; |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
974 |
26d0f350347a
Obsolete keypool and make sure database removes log files on shutdown.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1500
diff
changeset
|
975 if (nFileVersion < VERSION) // Update |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
976 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
977 // Get rid of old debug.log file in current directory |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
978 if (nFileVersion <= 105 && !pszSetDataDir[0]) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
979 unlink("debug.log"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
980 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
981 WriteVersion(VERSION); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
982 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
983 |
746 | 984 return DB_LOAD_OK; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
985 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
986 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
987 void ThreadFlushWalletDB(void* parg) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
988 { |
690 | 989 const string& strFile = ((const string*)parg)[0]; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
990 static bool fOneThread; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
991 if (fOneThread) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
992 return; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
993 fOneThread = true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
994 if (mapArgs.count("-noflushwallet")) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
995 return; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
996 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
997 unsigned int nLastSeen = nWalletDBUpdated; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
998 unsigned int nLastFlushed = nWalletDBUpdated; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
999 int64 nLastWalletUpdate = GetTime(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1000 while (!fShutdown) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1001 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1002 Sleep(500); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1003 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1004 if (nLastSeen != nWalletDBUpdated) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1005 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1006 nLastSeen = nWalletDBUpdated; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1007 nLastWalletUpdate = GetTime(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1008 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1009 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1010 if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1011 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1012 TRY_CRITICAL_BLOCK(cs_db) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1013 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1014 // Don't do this if any databases are in use |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1015 int nRefCount = 0; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1016 map<string, int>::iterator mi = mapFileUseCount.begin(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1017 while (mi != mapFileUseCount.end()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1018 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1019 nRefCount += (*mi).second; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1020 mi++; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1021 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1022 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1023 if (nRefCount == 0 && !fShutdown) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1024 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1025 map<string, int>::iterator mi = mapFileUseCount.find(strFile); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1026 if (mi != mapFileUseCount.end()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1027 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1028 printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1029 printf("Flushing wallet.dat\n"); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1030 nLastFlushed = nWalletDBUpdated; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1031 int64 nStart = GetTimeMillis(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1032 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1033 // Flush wallet.dat so it's self contained |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1034 CloseDb(strFile); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1035 dbenv.txn_checkpoint(0, 0, 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1036 dbenv.lsn_reset(strFile.c_str(), 0); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1037 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1038 mapFileUseCount.erase(mi++); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1039 printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1040 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1041 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1042 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1043 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1044 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1045 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1046 |
690 | 1047 bool BackupWallet(const CWallet& wallet, const string& strDest) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1048 { |
690 | 1049 if (!wallet.fFileBacked) |
1050 return false; | |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1051 while (!fShutdown) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1052 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1053 CRITICAL_BLOCK(cs_db) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1054 { |
690 | 1055 if (!mapFileUseCount.count(wallet.strWalletFile) || mapFileUseCount[wallet.strWalletFile] == 0) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1056 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1057 // Flush log data to the dat file |
690 | 1058 CloseDb(wallet.strWalletFile); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1059 dbenv.txn_checkpoint(0, 0, 0); |
690 | 1060 dbenv.lsn_reset(wallet.strWalletFile.c_str(), 0); |
1061 mapFileUseCount.erase(wallet.strWalletFile); | |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1062 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1063 // Copy wallet.dat |
690 | 1064 filesystem::path pathSrc(GetDataDir() + "/" + wallet.strWalletFile); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1065 filesystem::path pathDest(strDest); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1066 if (filesystem::is_directory(pathDest)) |
690 | 1067 pathDest = pathDest / wallet.strWalletFile; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1068 #if BOOST_VERSION >= 104000 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1069 filesystem::copy_file(pathSrc, pathDest, filesystem::copy_option::overwrite_if_exists); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1070 #else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1071 filesystem::copy_file(pathSrc, pathDest); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1072 #endif |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1073 printf("copied wallet.dat to %s\n", pathDest.string().c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1074 |
690 | 1075 return true; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1076 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1077 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1078 Sleep(100); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1079 } |
690 | 1080 return false; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1081 } |