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

Method Contents

src/leveldb/db/db_test.cc:339–362  ·  view source on GitHub ↗

Return a string that contains all key,value pairs in order, formatted like "(k1->v1)(k2->v2)".

Source from the content-addressed store, hash-verified

337 // Return a string that contains all key,value pairs in order,
338 // formatted like "(k1->v1)(k2->v2)".
339 std::string Contents() {
340 std::vector<std::string> forward;
341 std::string result;
342 Iterator* iter = db_->NewIterator(ReadOptions());
343 for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
344 std::string s = IterStatus(iter);
345 result.push_back('(');
346 result.append(s);
347 result.push_back(')');
348 forward.push_back(s);
349 }
350
351 // Check reverse iteration results are the reverse of forward results
352 size_t matched = 0;
353 for (iter->SeekToLast(); iter->Valid(); iter->Prev()) {
354 ASSERT_LT(matched, forward.size());
355 ASSERT_EQ(IterStatus(iter), forward[forward.size() - matched - 1]);
356 matched++;
357 }
358 ASSERT_EQ(matched, forward.size());
359
360 delete iter;
361 return result;
362 }
363
364 std::string AllEntriesFor(const Slice& user_key) {
365 Iterator* iter = dbfull()->TEST_NewInternalIterator();

Callers

nothing calls this directly

Calls 9

ReadOptionsClass · 0.50
NewIteratorMethod · 0.45
SeekToFirstMethod · 0.45
ValidMethod · 0.45
NextMethod · 0.45
push_backMethod · 0.45
SeekToLastMethod · 0.45
PrevMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected