| 263 | |
| 264 | template <typename K> |
| 265 | bool Exists(const K& key) const |
| 266 | { |
| 267 | CDataStream ssKey(SER_DISK, CLIENT_VERSION); |
| 268 | ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE); |
| 269 | ssKey << key; |
| 270 | leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size()); |
| 271 | |
| 272 | std::string strValue; |
| 273 | leveldb::Status status = pdb->Get(readoptions, slKey, &strValue); |
| 274 | if (!status.ok()) { |
| 275 | if (status.IsNotFound()) |
| 276 | return false; |
| 277 | LogPrintf("LevelDB read failure: %s\n", status.ToString()); |
| 278 | dbwrapper_private::HandleError(status); |
| 279 | } |
| 280 | return true; |
| 281 | } |
| 282 | |
| 283 | template <typename K> |
| 284 | bool Erase(const K& key, bool fSync = false) |