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

Method commit_db_txn

src/platform/DBmemory.cpp:135–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void DBmemory::commit_db_txn() {
136#ifdef __EMSCRIPTEN__
137 if (async_op) {
138 std::cout << "DBmemory::commit_db_txn kv previous op pending" << std::endl;
139 return; // previous operation pending
140 }
141 std::string committed_state;
142 committed_state.reserve(test_get_approximate_size() * 4 / 3);
143 common::StringOutputStream stream(committed_state);
144 // std::cout << "DBmemory::commit_db_txn kv count=" << storage.size() << std::endl;
145 stream.write_varint(storage.size());
146 for (const auto &item : storage) {
147 stream.write_varint(item.first.size());
148 stream.write(item.first);
149 stream.write_varint(item.second.size());
150 stream.write(item.second);
151 }
152 async_op =
153 std::make_unique<AsyncIndexDBOperation>(full_path, committed_state.data(), committed_state.size(), [=]() {
154 std::cout << "DBmemory::commit_db_txn async op finished" << std::endl;
155 async_op.reset();
156 });
157#endif
158}
159
160void DBmemory::put(const std::string &key, const common::BinaryArray &value, bool nooverwrite) {
161 auto res = storage.emplace(key, value);

Callers 1

run_testsMethod · 0.45

Calls 5

write_varintMethod · 0.80
sizeMethod · 0.45
writeMethod · 0.45
dataMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected