@@ -98,64 +98,59 @@ class BerkeleyBatch;
9898/* * An instance of this class represents one database.
9999 * For BerkeleyDB this is just a (env, strFile) tuple.
100100 **/
101- class BerkeleyDatabase
101+ class BerkeleyDatabase : public WalletDatabase
102102{
103103 friend class BerkeleyBatch ;
104104public:
105105 /* * Create dummy DB handle */
106- BerkeleyDatabase () : nUpdateCounter( 0 ), nLastSeen( 0 ), nLastFlushed( 0 ), nLastWalletUpdate( 0 ), env(nullptr )
106+ BerkeleyDatabase () : WalletDatabase( ), env(nullptr )
107107 {
108108 }
109109
110110 /* * Create DB handle to real database */
111111 BerkeleyDatabase (std::shared_ptr<BerkeleyEnvironment> env, std::string filename) :
112- nUpdateCounter ( 0 ), nLastSeen( 0 ), nLastFlushed( 0 ), nLastWalletUpdate( 0 ), env(std::move(env)), strFile(std::move(filename))
112+ WalletDatabase ( ), env(std::move(env)), strFile(std::move(filename))
113113 {
114114 auto inserted = this ->env ->m_databases .emplace (strFile, std::ref (*this ));
115115 assert (inserted.second );
116116 }
117117
118- ~BerkeleyDatabase ();
118+ ~BerkeleyDatabase () override ;
119119
120120 /* * Open the database if it is not already opened.
121121 * Dummy function, doesn't do anything right now, but is needed for class abstraction */
122- void Open (const char * mode);
122+ void Open (const char * mode) override ;
123123
124124 /* * Rewrite the entire database on disk, with the exception of key pszSkip if non-zero
125125 */
126- bool Rewrite (const char * pszSkip=nullptr );
126+ bool Rewrite (const char * pszSkip=nullptr ) override ;
127127
128128 /* * Indicate the a new database user has began using the database. */
129- void AddRef ();
129+ void AddRef () override ;
130130 /* * Indicate that database user has stopped using the database and that it could be flushed or closed. */
131- void RemoveRef ();
131+ void RemoveRef () override ;
132132
133133 /* * Back up the entire database to a file.
134134 */
135- bool Backup (const std::string& strDest) const ;
135+ bool Backup (const std::string& strDest) const override ;
136136
137137 /* * Make sure all changes are flushed to database file.
138138 */
139- void Flush ();
139+ void Flush () override ;
140140 /* * Flush to the database file and close the database.
141141 * Also close the environment if no other databases are open in it.
142142 */
143- void Close ();
143+ void Close () override ;
144144 /* flush the wallet passively (TRY_LOCK)
145145 ideal to be called periodically */
146- bool PeriodicFlush ();
146+ bool PeriodicFlush () override ;
147147
148- void IncrementUpdateCounter ();
149-
150- void ReloadDbEnv ();
148+ void IncrementUpdateCounter () override ;
151149
152- std::atomic<unsigned int > nUpdateCounter;
153- unsigned int nLastSeen;
154- unsigned int nLastFlushed;
155- int64_t nLastWalletUpdate;
150+ void ReloadDbEnv () override ;
156151
157152 /* * Verifies the environment and database file */
158- bool Verify (bilingual_str& error);
153+ bool Verify (bilingual_str& error) override ;
159154
160155 /* *
161156 * Pointer to shared database environment.
@@ -172,7 +167,7 @@ class BerkeleyDatabase
172167 std::unique_ptr<Db> m_db;
173168
174169 /* * Make a BerkeleyBatch connected to this database */
175- std::unique_ptr<BerkeleyBatch > MakeBatch (const char * mode, bool flush_on_close) ;
170+ std::unique_ptr<DatabaseBatch > MakeBatch (const char * mode = " r+ " , bool flush_on_close = true ) override ;
176171
177172private:
178173 std::string strFile;
0 commit comments