25
25
static const unsigned int DEFAULT_WALLET_DBLOGSIZE = 100 ;
26
26
static const bool DEFAULT_WALLET_PRIVDB = true ;
27
27
28
- class CDBEnv
28
+ class BerkeleyEnvironment
29
29
{
30
30
private:
31
31
bool fDbEnvInit ;
@@ -39,8 +39,8 @@ class CDBEnv
39
39
std::map<std::string, int > mapFileUseCount;
40
40
std::map<std::string, Db*> mapDb;
41
41
42
- CDBEnv (const fs::path& env_directory);
43
- ~CDBEnv ();
42
+ BerkeleyEnvironment (const fs::path& env_directory);
43
+ ~BerkeleyEnvironment ();
44
44
void Reset ();
45
45
46
46
void MakeMock ();
@@ -86,23 +86,23 @@ class CDBEnv
86
86
}
87
87
};
88
88
89
- /* * Get CDBEnv and database filename given a wallet path. */
90
- CDBEnv * GetWalletEnv (const fs::path& wallet_path, std::string& database_filename);
89
+ /* * Get BerkeleyEnvironment and database filename given a wallet path. */
90
+ BerkeleyEnvironment * GetWalletEnv (const fs::path& wallet_path, std::string& database_filename);
91
91
92
92
/* * An instance of this class represents one database.
93
93
* For BerkeleyDB this is just a (env, strFile) tuple.
94
94
**/
95
- class CWalletDBWrapper
95
+ class BerkeleyDatabase
96
96
{
97
- friend class CDB ;
97
+ friend class BerkeleyBatch ;
98
98
public:
99
99
/* * Create dummy DB handle */
100
- CWalletDBWrapper () : nUpdateCounter(0 ), nLastSeen(0 ), nLastFlushed(0 ), nLastWalletUpdate(0 ), env(nullptr )
100
+ BerkeleyDatabase () : nUpdateCounter(0 ), nLastSeen(0 ), nLastFlushed(0 ), nLastWalletUpdate(0 ), env(nullptr )
101
101
{
102
102
}
103
103
104
104
/* * Create DB handle to real database */
105
- CWalletDBWrapper (const fs::path& wallet_path, bool mock = false ) :
105
+ BerkeleyDatabase (const fs::path& wallet_path, bool mock = false ) :
106
106
nUpdateCounter (0 ), nLastSeen(0 ), nLastFlushed(0 ), nLastWalletUpdate(0 )
107
107
{
108
108
env = GetWalletEnv (wallet_path, strFile);
@@ -114,21 +114,21 @@ class CWalletDBWrapper
114
114
}
115
115
116
116
/* * Return object for accessing database at specified path. */
117
- static std::unique_ptr<CWalletDBWrapper > Create (const fs::path& path)
117
+ static std::unique_ptr<BerkeleyDatabase > Create (const fs::path& path)
118
118
{
119
- return MakeUnique<CWalletDBWrapper >(path);
119
+ return MakeUnique<BerkeleyDatabase >(path);
120
120
}
121
121
122
122
/* * Return object for accessing dummy database with no read/write capabilities. */
123
- static std::unique_ptr<CWalletDBWrapper > CreateDummy ()
123
+ static std::unique_ptr<BerkeleyDatabase > CreateDummy ()
124
124
{
125
- return MakeUnique<CWalletDBWrapper >();
125
+ return MakeUnique<BerkeleyDatabase >();
126
126
}
127
127
128
128
/* * Return object for accessing temporary in-memory database. */
129
- static std::unique_ptr<CWalletDBWrapper > CreateMock ()
129
+ static std::unique_ptr<BerkeleyDatabase > CreateMock ()
130
130
{
131
- return MakeUnique<CWalletDBWrapper >(" " , true /* mock */ );
131
+ return MakeUnique<BerkeleyDatabase >(" " , true /* mock */ );
132
132
}
133
133
134
134
/* * Rewrite the entire database on disk, with the exception of key pszSkip if non-zero
@@ -152,7 +152,7 @@ class CWalletDBWrapper
152
152
153
153
private:
154
154
/* * BerkeleyDB specific */
155
- CDBEnv *env;
155
+ BerkeleyEnvironment *env;
156
156
std::string strFile;
157
157
158
158
/* * Return whether this database handle is a dummy for testing.
@@ -164,34 +164,34 @@ class CWalletDBWrapper
164
164
165
165
166
166
/* * RAII class that provides access to a Berkeley database */
167
- class CDB
167
+ class BerkeleyBatch
168
168
{
169
169
protected:
170
170
Db* pdb;
171
171
std::string strFile;
172
172
DbTxn* activeTxn;
173
173
bool fReadOnly ;
174
174
bool fFlushOnClose ;
175
- CDBEnv *env;
175
+ BerkeleyEnvironment *env;
176
176
177
177
public:
178
- explicit CDB (CWalletDBWrapper& dbw , const char * pszMode = " r+" , bool fFlushOnCloseIn =true );
179
- ~CDB () { Close (); }
178
+ explicit BerkeleyBatch (BerkeleyDatabase& database , const char * pszMode = " r+" , bool fFlushOnCloseIn =true );
179
+ ~BerkeleyBatch () { Close (); }
180
180
181
- CDB (const CDB &) = delete ;
182
- CDB & operator =(const CDB &) = delete ;
181
+ BerkeleyBatch (const BerkeleyBatch &) = delete ;
182
+ BerkeleyBatch & operator =(const BerkeleyBatch &) = delete ;
183
183
184
184
void Flush ();
185
185
void Close ();
186
186
static bool Recover (const fs::path& file_path, void *callbackDataIn, bool (*recoverKVcallback)(void * callbackData, CDataStream ssKey, CDataStream ssValue), std::string& out_backup_filename);
187
187
188
188
/* flush the wallet passively (TRY_LOCK)
189
189
ideal to be called periodically */
190
- static bool PeriodicFlush (CWalletDBWrapper& dbw );
190
+ static bool PeriodicFlush (BerkeleyDatabase& database );
191
191
/* verifies the database environment */
192
192
static bool VerifyEnvironment (const fs::path& file_path, std::string& errorStr);
193
193
/* verifies the database file */
194
- static bool VerifyDatabaseFile (const fs::path& file_path, std::string& warningStr, std::string& errorStr, CDBEnv ::recoverFunc_type recoverFunc);
194
+ static bool VerifyDatabaseFile (const fs::path& file_path, std::string& warningStr, std::string& errorStr, BerkeleyEnvironment ::recoverFunc_type recoverFunc);
195
195
196
196
public:
197
197
template <typename K, typename T>
@@ -387,7 +387,7 @@ class CDB
387
387
return Write (std::string (" version" ), nVersion);
388
388
}
389
389
390
- bool static Rewrite (CWalletDBWrapper& dbw , const char * pszSkip = nullptr );
390
+ bool static Rewrite (BerkeleyDatabase& database , const char * pszSkip = nullptr );
391
391
};
392
392
393
393
#endif // BITCOIN_WALLET_DB_H
0 commit comments