MCPcopy Create free account
hub / github.com/LUX-Core/lux / Read

Method Read

src/leveldbwrapper.h:95–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93
94 template <typename K, typename V>
95 bool Read(const K& key, V& value) const
96 {
97 CDataStream ssKey(SER_DISK, CLIENT_VERSION);
98 ssKey.reserve(ssKey.GetSerializeSize(key));
99 ssKey << key;
100 leveldb::Slice slKey(ssKey.data(), ssKey.size());
101
102 std::string strValue;
103 leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
104 if (!status.ok()) {
105 if (status.IsNotFound())
106 return false;
107 LogPrintf("LevelDB read failure: %s\n", status.ToString());
108 HandleError(status);
109 }
110 try {
111 CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION);
112 ssValue >> value;
113 } catch (const std::exception&) {
114 return false;
115 }
116 return true;
117 }
118
119 template <typename K, typename V>
120 bool Write(const K& key, const V& value, bool fSync = false)

Callers

nothing calls this directly

Calls 9

HandleErrorFunction · 0.85
IsNotFoundMethod · 0.80
reserveMethod · 0.45
GetSerializeSizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
GetMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected