MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / Open

Method Open

src/wallet/db.cpp:87–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87bool CDBEnv::Open(const boost::filesystem::path& pathIn)
88{
89 if (fDbEnvInit)
90 return true;
91
92 boost::this_thread::interruption_point();
93
94 path = pathIn;
95 boost::filesystem::path pathLogDir = path / "database";
96 TryCreateDirectory(pathLogDir);
97 boost::filesystem::path pathErrorFile = path / "dberr.log";
98 LogPrint(BCLog::CDB,"CDBEnv::Open: LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
99
100 unsigned int nEnvFlags = 0;
101 if (SysCfg().GetBoolArg("-privdb", true))
102 nEnvFlags |= DB_PRIVATE;
103
104 dbenv->set_lg_dir(pathLogDir.string().c_str());
105 dbenv->set_cachesize(0, 0x100000, 1); // 1 MiB should be enough for just the wallet
106 dbenv->set_lg_bsize(0x10000);
107 dbenv->set_lg_max(1048576);
108 dbenv->set_lk_max_locks(40000);
109 dbenv->set_lk_max_objects(40000);
110 err_file = fopen(pathErrorFile.string().c_str(), "a");
111 dbenv->set_errfile(err_file); /// debug
112 dbenv->set_flags(DB_AUTO_COMMIT, 1);
113 dbenv->set_flags(DB_TXN_WRITE_NOSYNC, 1);
114 dbenv->log_set_config(DB_LOG_AUTO_REMOVE, 1);
115 int ret = dbenv->open(path.string().c_str(),
116 DB_CREATE |
117 DB_INIT_LOCK |
118 DB_INIT_LOG |
119 DB_INIT_MPOOL |
120 DB_INIT_TXN |
121 DB_THREAD |
122 DB_RECOVER |
123 nEnvFlags,
124 S_IRUSR | S_IWUSR);
125 if (ret != 0)
126 return ERRORMSG(strprintf("CDBEnv::Open: Error %d opening database environment: %s\n", ret, DbEnv::strerror(ret)).c_str());
127
128 fDbEnvInit = true;
129 fMockDb = false;
130 return true;
131}
132
133void CDBEnv::MakeMock()
134{

Callers 2

CDBMethod · 0.45
StartUpMethod · 0.45

Calls 4

TryCreateDirectoryFunction · 0.85
fopenFunction · 0.85
GetBoolArgMethod · 0.80
openMethod · 0.80

Tested by

no test coverage detected