| 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) |
nothing calls this directly
no test coverage detected