SKALE-3023 fix getLatestCreatedKey command

parent 4f606e2a
......@@ -192,7 +192,7 @@ stringstream LevelDB::getAllKeys() {
// old style keys
value = " VALUE: " + it->value().ToString();
}
result << "KEY: " << key << ',' << value << '\n';
result << "KEY: " << key << ',' << value << std::endl;
}
result << "TOTAL NUMBER OF KEYS: " << counter << '\n';
......@@ -211,8 +211,8 @@ pair<string, uint64_t> LevelDB::getLatestCreatedKey() {
Json::Reader reader;
reader.parse(it->value().ToString().c_str(), key_data);
if (key_data["timestamp"].asUInt64() > latest_timestamp) {
latest_timestamp = key_data["timestamp"].asUInt64();
if (std::stoi(key_data["timestamp"].asString()) > latest_timestamp) {
latest_timestamp = std::stoi(key_data["timestamp"].asString());
latest_created_key_name = it->key().ToString();
}
} else {
......
......@@ -89,12 +89,8 @@ public:
void throwExceptionOnError(leveldb::Status result);
LevelDB(string& filename);
class KeyVisitor {
public:
virtual void visitDBKey(const char* _data) = 0;
......
......@@ -58,7 +58,7 @@ void getLatestCreatedKey() {
std::cout << "Info client inited" << std::endl;
Json::Value lastCreatedKey = c.getLatestCreatedKey();
std::cout << "Last created key name: " << lastCreatedKey["keyName"] << std::endl;
std::cout << "Last created key creation time: " << lastCreatedKey["creationTime"] << std::endl;
std::cout << "Last created key creation time: " << std::stoi(lastCreatedKey["creationTime"].asString()) << std::endl;
exit(0);
}
......@@ -102,9 +102,9 @@ void isKeyExists(const std::string& key) {
StubClient c(client, jsonrpc::JSONRPC_CLIENT_V2);
std::cout << "Info client inited" << std::endl;
if (c.isKeyExist(key)["IsExist"].asBool()) {
std::cout << "Key with name " << key << "presents in server database.\n";
std::cout << "Key with name " << key << " presents in server database.\n";
} else {
std::cout << "Key with name " << key << "does not exist in server's database.\n";
std::cout << "Key with name " << key << " does not exist in server's database.\n";
}
exit(0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment