| 305 | } |
| 306 | |
| 307 | BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const bool read_only, bool fFlushOnCloseIn) : pdb(nullptr), activeTxn(nullptr), m_cursor(nullptr), m_database(database) |
| 308 | { |
| 309 | database.AddRef(); |
| 310 | database.Open(); |
| 311 | fReadOnly = read_only; |
| 312 | fFlushOnClose = fFlushOnCloseIn; |
| 313 | env = database.env.get(); |
| 314 | pdb = database.m_db.get(); |
| 315 | strFile = database.strFile; |
| 316 | if (!Exists(std::string("version"))) { |
| 317 | bool fTmp = fReadOnly; |
| 318 | fReadOnly = false; |
| 319 | Write(std::string("version"), CLIENT_VERSION); |
| 320 | fReadOnly = fTmp; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | void BerkeleyDatabase::Open() |
| 325 | { |