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

Automatically integrates git build information into executables.

Usage:
func.exe -V
adnl-pong -V
validator-engine -V
and so on.
Result will be shown in the following format:
Func build information: [ Commit: d8b751d7a5, Date: 2021-02-27 14:34:41 +0200]
This commit is contained in:
Alex Melman 2021-03-26 00:26:49 +02:00 committed by main
parent 41a3418b7b
commit bab4c1637e
40 changed files with 492 additions and 78 deletions

View file

@ -45,7 +45,7 @@ target_include_directories(storage PUBLIC
add_executable(storage-cli ${STORAGE_CLI_SOURCE})
target_link_libraries(storage-cli storage overlay tdutils tdactor adnl tl_api dht
rldp rldp2 catchain validatorsession full-node validator ton_validator validator
fift-lib memprof terminal ${JEMALLOC_LIBRARIES})
fift-lib memprof terminal git ${JEMALLOC_LIBRARIES})
set(STORAGE_TEST_SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/test/storage.cpp

View file

@ -22,7 +22,7 @@
#include "td/utils/format.h"
namespace ton {
void LoadSpeed::add(td::size_t size, td::Timestamp now) {
void LoadSpeed::add(std::size_t size, td::Timestamp now) {
total_size_ += size;
events_.push(Event{size, now});
update(now);

View file

@ -26,17 +26,17 @@
namespace ton {
class LoadSpeed {
public:
void add(td::size_t size, td::Timestamp now);
void add(std::size_t size, td::Timestamp now);
double speed(td::Timestamp now = td::Timestamp::now()) const;
friend td::StringBuilder &operator<<(td::StringBuilder &sb, const LoadSpeed &speed);
private:
struct Event {
td::size_t size;
std::size_t size;
td::Timestamp at;
};
mutable td::VectorQueue<Event> events_;
mutable td::size_t total_size_{0};
mutable std::size_t total_size_{0};
double duration() const;
void update(td::Timestamp now) const;

View file

@ -138,7 +138,7 @@ void MerkleTree::init_finish() {
CHECK(root_hash_);
}
void MerkleTree::remove_chunk(td::size_t index) {
void MerkleTree::remove_chunk(std::size_t index) {
CHECK(index < n_);
index += n_;
while (proof_[index].not_null()) {
@ -147,13 +147,13 @@ void MerkleTree::remove_chunk(td::size_t index) {
}
}
bool MerkleTree::has_chunk(td::size_t index) const {
bool MerkleTree::has_chunk(std::size_t index) const {
CHECK(index < n_);
index += n_;
return proof_[index].not_null();
}
void MerkleTree::add_chunk(td::size_t index, td::Slice hash) {
void MerkleTree::add_chunk(std::size_t index, td::Slice hash) {
CHECK(hash.size() == 32);
CHECK(index < n_);
index += n_;

View file

@ -39,7 +39,7 @@ class MerkleTree {
MerkleTree(size_t chunks_count, td::Ref<vm::Cell> root_proof);
struct Chunk {
td::size_t index{0};
std::size_t index{0};
td::Bits256 hash;
};
@ -47,7 +47,7 @@ class MerkleTree {
MerkleTree() = default;
void init_begin(size_t chunks_count);
void init_add_chunk(td::size_t index, td::Slice hash);
void init_add_chunk(std::size_t index, td::Slice hash);
void init_finish();
// merge external proof with an existing proof
@ -70,20 +70,20 @@ class MerkleTree {
private:
td::uint64 total_blocks_;
td::size_t n_; // n = 2^log_n
std::size_t n_; // n = 2^log_n
td::uint32 log_n_;
td::size_t mark_id_{0};
std::vector<td::size_t> mark_; // n_ * 2
std::size_t mark_id_{0};
std::vector<std::size_t> mark_; // n_ * 2
std::vector<td::Ref<vm::Cell>> proof_; // n_ * 2
td::optional<td::Bits256> root_hash_;
td::Ref<vm::Cell> root_proof_;
td::Status validate_proof(td::Ref<vm::Cell> new_root);
bool has_chunk(td::size_t index) const;
void remove_chunk(td::size_t index);
bool has_chunk(std::size_t index) const;
void remove_chunk(std::size_t index);
void add_chunk(td::size_t index, td::Slice hash);
void add_chunk(std::size_t index, td::Slice hash);
void init_proof();
td::Ref<vm::Cell> merge(td::Ref<vm::Cell> root, size_t index);

View file

@ -51,6 +51,7 @@
#include <limits>
#include <map>
#include <set>
#include "git.h"
namespace ton_rldp = ton::rldp2;
@ -749,7 +750,7 @@ class StorageCli : public td::actor::Actor {
auto file_id_str = parser.read_word();
size_t file_id = std::numeric_limits<size_t>::max();
if (file_id_str != "*") {
TRY_RESULT_PROMISE_ASSIGN(promise, file_id, td::to_integer_safe<td::size_t>(file_id_str));
TRY_RESULT_PROMISE_ASSIGN(promise, file_id, td::to_integer_safe<std::size_t>(file_id_str));
}
TRY_RESULT_PROMISE(promise, priority, td::to_integer_safe<td::uint8>(parser.read_word()));
if (priority == 255) {
@ -837,6 +838,10 @@ int main(int argc, char *argv[]) {
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(FATAL) + verbosity);
return (verbosity >= 0 && verbosity <= 20) ? td::Status::OK() : td::Status::Error("verbosity must be 0..20");
});
p.add_option('V', "version", "shows storage-cli build information", [&]() {
std::cout << "storage-cli build information: [ Commit: " << GitMetadata::CommitSHA1() << ", Date: " << GitMetadata::CommitDate() << "]\n";
std::exit(0);
});
p.add_option('C', "config", "set ton config", [&](td::Slice arg) { options.config = arg.str(); });
p.add_option('D', "db", "root for dbs", [&](td::Slice fname) { options.db_root = fname.str(); });
p.add_checked_option('I', "ip", "set ip:port", [&](td::Slice arg) {