1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

More detailed validator session stats

This commit is contained in:
SpyCheese 2022-07-05 23:44:36 +03:00 committed by EmelyanenkoK
parent b3e6819f3f
commit 417c3bb640
6 changed files with 118 additions and 47 deletions

View file

@ -2523,14 +2523,22 @@ void ValidatorManagerImpl::log_validator_session_stats(BlockIdExt block_id,
if (fname.empty()) {
return;
}
std::vector<td::Bits256> producers;
for (const PublicKeyHash& id : stats.producers) {
producers.push_back(id.bits256_value());
std::vector<tl_object_ptr<ton_api::validatorSession_statsRound>> rounds;
for (const auto& round : stats.rounds) {
std::vector<tl_object_ptr<ton_api::validatorSession_statsProducer>> producers;
for (const auto& producer : round.producers) {
producers.push_back(create_tl_object<ton_api::validatorSession_statsProducer>(
producer.id.bits256_value(), producer.block_status, producer.block_timestamp));
}
rounds.push_back(create_tl_object<ton_api::validatorSession_statsRound>(round.timestamp, std::move(producers)));
}
auto obj = create_tl_object<ton_api::validatorSession_stats>(
create_tl_block_id_simple(block_id.id), stats.round, stats.total_validators, stats.total_weight,
stats.signatures, stats.signatures_weight, stats.approve_signatures, stats.approve_signatures_weight,
stats.creator.bits256_value(), std::move(producers));
create_tl_block_id_simple(block_id.id), stats.timestamp, stats.self.bits256_value(),
stats.creator.bits256_value(), stats.total_validators, stats.total_weight, stats.signatures,
stats.signatures_weight, stats.approve_signatures, stats.approve_signatures_weight, stats.first_round,
std::move(rounds));
std::string s = td::json_encode<std::string>(td::ToJson(*obj.get()), false);
s.erase(std::remove_if(s.begin(), s.end(), [](char c) { return c == '\n' || c == '\r'; }), s.end());