| 176 | |
| 177 | template<typename V> |
| 178 | bool Read(std::string key, V &value) { |
| 179 | leveldb::Slice slKey(key); |
| 180 | |
| 181 | string strValue; |
| 182 | leveldb::Status status = pdb->Get(readoptions, slKey, &strValue); |
| 183 | if (!status.ok()) { |
| 184 | if (status.IsNotFound()) |
| 185 | return false; |
| 186 | LogPrint(BCLog::INFO,"LevelDB read failure: %s\n", status.ToString().c_str()); |
| 187 | ThrowError(status); |
| 188 | } |
| 189 | try { |
| 190 | CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION); |
| 191 | ssValue >> value; |
| 192 | } catch(std::exception &e) { |
| 193 | return false; |
| 194 | } |
| 195 | return true; |
| 196 | } |
| 197 | |
| 198 | template<typename V> |
| 199 | bool Write(const std::string &key, const V &value, bool fSync = false) { |
nothing calls this directly
no test coverage detected