Skip to content

Commit cd95a82

Browse files
author
nkumar4
committed
Fixed clang-tidy error
1 parent d9e636b commit cd95a82

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

kvbc/tools/state_snapshot_with_acl/state_snapshot_with_acl_tool.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ int run(int argc, char* argv[]) {
147147
const auto rocksdb_conf = config["rocksdb-config-file"].as<std::string>();
148148
const auto client_id = (config["client-id"].empty() ? std::string{} : config["client-id"].as<std::string>());
149149
const auto ext_ev_group_id = config["ext-event-group-id"].as<std::int64_t>();
150-
(void)ext_ev_group_id;
151150

152151
if (point_lookup_batch_size < 1) {
153152
std::cerr << "point-lookup-batch-size must be greater than or equal to 1" << std::endl;
@@ -168,7 +167,9 @@ int run(int argc, char* argv[]) {
168167
}
169168
auto thread_pool = ThreadPool{static_cast<std::uint32_t>(point_lookup_threads)};
170169

171-
std::cout << "Prining ACS state {key, Hash(val)} with a point lookup batch size = " << point_lookup_batch_size
170+
std::cout << "Hash state keys {H(H(k1)|H(v1) | H(k2)|H(v2) .....H(kn|vn))} acl-filtered for client id: " << client_id
171+
<< ", starting from an offset(event group id) " << ext_ev_group_id
172+
<< ", with a point lookup batch size = " << point_lookup_batch_size
172173
<< ", point lookup threads = " << point_lookup_threads
173174
<< ", RocksDB block cache size = " << rocksdb_cache_size << " bytes, configuration file = " << rocksdb_conf
174175
<< ", DB path = " << rocksdb_path << std::endl;
@@ -220,8 +221,10 @@ int run(int argc, char* argv[]) {
220221
static_cast<std::uint32_t>(point_lookup_threads)};
221222

222223
auto print_kv_with_acl = [&](const Buffer& buff, const auto& value, const auto& trids, bool is_public) {
224+
//In actual application, we would probably stream state keys {k , hash(v) } over grpc
225+
//here we are just printing it
223226
std::ostringstream oss;
224-
const auto hash = Hash(SHA3_256().digest(value.data(), value.size()));
227+
const auto hash = Hash(SHA2_256().digest(value.data(), value.size()));
225228
oss << "key: " << bufferToHex(buff.data(), buff.size()) << std::endl;
226229
oss << "hash(val): " << bufferToHex(hash.data(), hash.size()) << std::endl;
227230
if (is_public)
@@ -241,7 +244,7 @@ int run(int argc, char* argv[]) {
241244
std::cout << oss.str();
242245
};
243246

244-
auto has_access = [&num_of_pvt_keys, &num_of_public_keys, &client_id](const auto& value, const auto& trids) -> bool {
247+
auto has_access = [&num_of_pvt_keys, &num_of_public_keys, &client_id](const auto& trids) -> bool {
245248
bool allowed = false;
246249
if (trids.size()) {
247250
for (const auto& trid : trids) {
@@ -321,15 +324,15 @@ int run(int argc, char* argv[]) {
321324
auto v = std::unique_ptr<std::string>(proto.release_value());
322325
value.assign(std::move(*v));
323326
for (auto& t : proto.trid()) {
324-
trids.emplace_back(std::move(t));
327+
trids.emplace_back(t);
325328
}
326329

327-
if (has_access(*v, trids)) {
328-
hash_state_kv(serialized_keys[j], *v);
330+
if (has_access(trids)) {
331+
hash_state_kv(serialized_keys[j], value);
329332
}
330333
// print all state keys - hash(val), trid
331-
// auto is_public = trids.size() ? false : true;
332-
// print_kv_with_acl(serialized_keys[j], value, trids, is_public);
334+
//auto is_public = trids.size() ? false : true;
335+
//print_kv_with_acl(serialized_keys[j], value, trids, is_public);
333336
++key_idx;
334337
}
335338
}

0 commit comments

Comments
 (0)