MCPcopy Create free account
hub / github.com/LUX-Core/lux / MakeMock

Method MakeMock

src/db.cpp:146–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void CDBEnv::MakeMock()
147{
148 if (fDbEnvInit)
149 throw runtime_error("CDBEnv::MakeMock : Already initialized");
150
151 boost::this_thread::interruption_point();
152
153 LogPrint("db", "CDBEnv::MakeMock\n");
154
155 dbenv->set_cachesize(1, 0, 1);
156 dbenv->set_lg_bsize(10485760 * 4);
157 dbenv->set_lg_max(10485760);
158 dbenv->set_lk_max_locks(10000);
159 dbenv->set_lk_max_objects(10000);
160 dbenv->set_flags(DB_AUTO_COMMIT, 1);
161 dbenv->log_set_config(DB_LOG_IN_MEMORY, 1);
162 int ret = dbenv->open(NULL,
163 DB_CREATE |
164 DB_INIT_LOCK |
165 DB_INIT_LOG |
166 DB_INIT_MPOOL |
167 DB_INIT_TXN |
168 DB_THREAD |
169 DB_PRIVATE,
170 S_IRUSR | S_IWUSR);
171 if (ret != 0)
172 {
173 LogPrintf("CDBEnv::MakeMock : Error %d opening database environment: %s\n", ret, DbEnv::strerror(ret));
174
175 // According to Berkeley DB specification, we must call dbenv.close() method on failure
176 int ret = dbenv->close(0);
177 if (ret != 0)
178 {
179 LogPrintf("CDBEnv::MakeMock : Error %d shutting down database environment: %s\n", ret, DbEnv::strerror(ret));
180 }
181 throw runtime_error(strprintf("CDBEnv::MakeMock : Error %d opening database environment.", ret));
182 }
183
184 fDbEnvInit = true;
185 fMockDb = true;
186}
187
188CDBEnv::VerifyResult CDBEnv::Verify(std::string strFile, bool (*recoverFunc)(CDBEnv& dbenv, std::string strFile))
189{

Callers 1

TestingSetupMethod · 0.80

Calls 3

LogPrintFunction · 0.85
openMethod · 0.45
closeMethod · 0.45

Tested by 1

TestingSetupMethod · 0.64