MCPcopy Create free account
hub / github.com/ElementsProject/elements / NewDB

Method NewDB

src/leveldb/db/db_impl.cc:182–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182Status DBImpl::NewDB() {
183 VersionEdit new_db;
184 new_db.SetComparatorName(user_comparator()->Name());
185 new_db.SetLogNumber(0);
186 new_db.SetNextFile(2);
187 new_db.SetLastSequence(0);
188
189 const std::string manifest = DescriptorFileName(dbname_, 1);
190 WritableFile* file;
191 Status s = env_->NewWritableFile(manifest, &file);
192 if (!s.ok()) {
193 return s;
194 }
195 {
196 log::Writer log(file);
197 std::string record;
198 new_db.EncodeTo(&record);
199 s = log.AddRecord(record);
200 if (s.ok()) {
201 s = file->Close();
202 }
203 }
204 delete file;
205 if (s.ok()) {
206 // Make "CURRENT" file that points to the new manifest file.
207 s = SetCurrentFile(env_, dbname_, 1);
208 } else {
209 env_->DeleteFile(manifest);
210 }
211 return s;
212}
213
214void DBImpl::MaybeIgnoreError(Status* s) const {
215 if (s->ok() || options_.paranoid_checks) {

Callers

nothing calls this directly

Calls 12

DescriptorFileNameFunction · 0.85
SetCurrentFileFunction · 0.85
SetComparatorNameMethod · 0.80
SetLogNumberMethod · 0.80
SetNextFileMethod · 0.80
AddRecordMethod · 0.80
NameMethod · 0.45
SetLastSequenceMethod · 0.45
NewWritableFileMethod · 0.45
EncodeToMethod · 0.45
CloseMethod · 0.45
DeleteFileMethod · 0.45

Tested by

no test coverage detected