SKALE-3023 fix getLatestCreatedKey command

parent 4f606e2a
...@@ -192,7 +192,7 @@ stringstream LevelDB::getAllKeys() { ...@@ -192,7 +192,7 @@ stringstream LevelDB::getAllKeys() {
// old style keys // old style keys
value = " VALUE: " + it->value().ToString(); value = " VALUE: " + it->value().ToString();
} }
result << "KEY: " << key << ',' << value << '\n'; result << "KEY: " << key << ',' << value << std::endl;
} }
result << "TOTAL NUMBER OF KEYS: " << counter << '\n'; result << "TOTAL NUMBER OF KEYS: " << counter << '\n';
...@@ -211,8 +211,8 @@ pair<string, uint64_t> LevelDB::getLatestCreatedKey() { ...@@ -211,8 +211,8 @@ pair<string, uint64_t> LevelDB::getLatestCreatedKey() {
Json::Reader reader; Json::Reader reader;
reader.parse(it->value().ToString().c_str(), key_data); reader.parse(it->value().ToString().c_str(), key_data);
if (key_data["timestamp"].asUInt64() > latest_timestamp) { if (std::stoi(key_data["timestamp"].asString()) > latest_timestamp) {
latest_timestamp = key_data["timestamp"].asUInt64(); latest_timestamp = std::stoi(key_data["timestamp"].asString());
latest_created_key_name = it->key().ToString(); latest_created_key_name = it->key().ToString();
} }
} else { } else {
......
...@@ -89,12 +89,8 @@ public: ...@@ -89,12 +89,8 @@ public:
void throwExceptionOnError(leveldb::Status result); void throwExceptionOnError(leveldb::Status result);
LevelDB(string& filename); LevelDB(string& filename);
class KeyVisitor { class KeyVisitor {
public: public:
virtual void visitDBKey(const char* _data) = 0; virtual void visitDBKey(const char* _data) = 0;
......
...@@ -58,7 +58,7 @@ void getLatestCreatedKey() { ...@@ -58,7 +58,7 @@ void getLatestCreatedKey() {
std::cout << "Info client inited" << std::endl; std::cout << "Info client inited" << std::endl;
Json::Value lastCreatedKey = c.getLatestCreatedKey(); Json::Value lastCreatedKey = c.getLatestCreatedKey();
std::cout << "Last created key name: " << lastCreatedKey["keyName"] << std::endl; 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); exit(0);
} }
...@@ -102,9 +102,9 @@ void isKeyExists(const std::string& key) { ...@@ -102,9 +102,9 @@ void isKeyExists(const std::string& key) {
StubClient c(client, jsonrpc::JSONRPC_CLIENT_V2); StubClient c(client, jsonrpc::JSONRPC_CLIENT_V2);
std::cout << "Info client inited" << std::endl; std::cout << "Info client inited" << std::endl;
if (c.isKeyExist(key)["IsExist"].asBool()) { 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 { } 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); 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