SKALE-3023 pretify getAllKeysInfo command

parent dbdf3e8a
...@@ -187,14 +187,14 @@ stringstream LevelDB::getAllKeys() { ...@@ -187,14 +187,14 @@ stringstream LevelDB::getAllKeys() {
reader.parse(it->value().ToString().c_str(), key_data); reader.parse(it->value().ToString().c_str(), key_data);
string timestamp_to_date_command = "date -d @" + key_data["timestamp"].asString(); string timestamp_to_date_command = "date -d @" + key_data["timestamp"].asString();
value = " VALUE: " + key_data["value"].asString() + ", TIMESTAMP: " + exec(timestamp_to_date_command.c_str()); value = " VALUE: " + key_data["value"].asString() + ", TIMESTAMP: " + exec(timestamp_to_date_command.c_str()) + '\n';
} else { } else {
// old style keys // old style keys
value = " VALUE: " + it->value().ToString(); value = " VALUE: " + it->value().ToString();
} }
result << "KEY: " << key << ',' << value << std::endl; result << "KEY: " << key << ',' << value;
} }
result << "TOTAL NUMBER OF KEYS: " << counter << '\n'; result << "TOTAL NUMBER OF KEYS: " << counter;
return result; return result;
} }
...@@ -202,7 +202,7 @@ stringstream LevelDB::getAllKeys() { ...@@ -202,7 +202,7 @@ stringstream LevelDB::getAllKeys() {
pair<string, uint64_t> LevelDB::getLatestCreatedKey() { pair<string, uint64_t> LevelDB::getLatestCreatedKey() {
leveldb::Iterator *it = db->NewIterator(readOptions); leveldb::Iterator *it = db->NewIterator(readOptions);
uint64_t latest_timestamp = 0; int64_t latest_timestamp = 0;
string latest_created_key_name = ""; string latest_created_key_name = "";
for (it->SeekToFirst(); it->Valid(); it->Next()) { for (it->SeekToFirst(); it->Valid(); it->Next()) {
if (it->value().ToString()[0] == '{') { if (it->value().ToString()[0] == '{') {
......
...@@ -49,7 +49,7 @@ void getAllKeysInfo() { ...@@ -49,7 +49,7 @@ void getAllKeysInfo() {
jsonrpc::HttpClient client("http://localhost:1030"); jsonrpc::HttpClient client("http://localhost:1030");
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;
std::cout << c.getAllKeysInfo()["allKeys"] << std::endl; std::cout << c.getAllKeysInfo()["allKeys"].asString().c_str() << std::endl;
exit(0); exit(0);
} }
...@@ -60,7 +60,7 @@ void getLatestCreatedKey() { ...@@ -60,7 +60,7 @@ void getLatestCreatedKey() {
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::string timestamp_to_date_command = "date -d @" + lastCreatedKey["creationTime"].asString(); std::string timestamp_to_date_command = "date -d @" + lastCreatedKey["creationTime"].asString();
std::cout << "Last created key creation time: " << exec(timestamp_to_date_command.c_str()) << std::endl; std::cout << "Last created key creation time: " << exec(timestamp_to_date_command.c_str());
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