MCPcopy Create free account
hub / github.com/bcndev/bytecoin / Cursor

Method Cursor

src/platform/DBlmdb.cpp:123–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123DBlmdb::Cursor::Cursor(
124 lmdb::Cur &&cur, const std::string &prefix, const std::string &middle, size_t max_key_size, bool forward)
125 : db_cur(std::move(cur)), prefix(prefix), forward(forward) {
126 std::string start = prefix + middle;
127 lmdb::Val itkey(start);
128 if (forward)
129 is_end = !db_cur.get(itkey, data, start.empty() ? MDB_FIRST : MDB_SET_RANGE);
130 else {
131 if (start.empty())
132 is_end = !db_cur.get(itkey, data, MDB_LAST);
133 else {
134 if (start.size() < max_key_size)
135 start += std::string(max_key_size - start.size(), char(0xff));
136 itkey = lmdb::Val(start);
137 is_end = !db_cur.get(itkey, data, MDB_SET_RANGE);
138 is_end = !db_cur.get(itkey, data,
139 is_end ? MDB_LAST : MDB_PREV); // If failed to find a key >= prefix, then it should be last in db
140 }
141 }
142 check_prefix(itkey);
143}
144
145void DBlmdb::Cursor::next() {
146 lmdb::Val itkey;

Callers

nothing calls this directly

Calls 4

ValClass · 0.85
getMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected