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

Method Read

src/dbwrapper.h:231–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229
230 template <typename K, typename V>
231 bool Read(const K& key, V& value) const
232 {
233 CDataStream ssKey(SER_DISK, CLIENT_VERSION);
234 ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
235 ssKey << key;
236 leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
237
238 std::string strValue;
239 leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
240 if (!status.ok()) {
241 if (status.IsNotFound())
242 return false;
243 LogPrintf("LevelDB read failure: %s\n", status.ToString());
244 dbwrapper_private::HandleError(status);
245 }
246 try {
247 CDataStream ssValue{MakeByteSpan(strValue), SER_DISK, CLIENT_VERSION};
248 ssValue.Xor(obfuscate_key);
249 ssValue >> value;
250 } catch (const std::exception&) {
251 return false;
252 }
253 return true;
254 }
255
256 template <typename K, typename V>
257 bool Write(const K& key, const V& value, bool fSync = false)

Callers

nothing calls this directly

Calls 8

HandleErrorFunction · 0.85
MakeByteSpanFunction · 0.85
XorMethod · 0.80
reserveMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
GetMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected