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

pow-testgiver support

This commit is contained in:
ton 2020-07-06 17:07:20 +03:00
parent dbde9c1c40
commit f064b1047a
257 changed files with 6665 additions and 2608 deletions

View file

@ -50,7 +50,7 @@ void Neighbour::update_proto_version(const ton_api::tonNode_capabilities &q) {
capabilities = q.capabilities_;
}
void Neighbour::query_success(td::Clocks::Duration t) {
void Neighbour::query_success(double t) {
unreliability--;
if (unreliability < 0) {
unreliability = 0;
@ -62,7 +62,7 @@ void Neighbour::query_failed() {
unreliability++;
}
void Neighbour::update_roundtrip(td::Clocks::Duration t) {
void Neighbour::update_roundtrip(double t) {
roundtrip = (t + roundtrip) * 0.5;
}
@ -938,7 +938,7 @@ const Neighbour &FullNodeShardImpl::choose_neighbour() const {
return best ? *best : Neighbour::zero;
}
void FullNodeShardImpl::update_neighbour_stats(adnl::AdnlNodeIdShort adnl_id, td::Clocks::Duration t, bool success) {
void FullNodeShardImpl::update_neighbour_stats(adnl::AdnlNodeIdShort adnl_id, double t, bool success) {
auto it = neighbours_.find(adnl_id);
if (it != neighbours_.end()) {
if (success) {
@ -949,7 +949,7 @@ void FullNodeShardImpl::update_neighbour_stats(adnl::AdnlNodeIdShort adnl_id, td
}
}
void FullNodeShardImpl::got_neighbour_capabilities(adnl::AdnlNodeIdShort adnl_id, td::Clocks::Duration t,
void FullNodeShardImpl::got_neighbour_capabilities(adnl::AdnlNodeIdShort adnl_id, double t,
td::BufferSlice data) {
auto it = neighbours_.find(adnl_id);
if (it == neighbours_.end()) {

View file

@ -30,17 +30,17 @@ struct Neighbour {
adnl::AdnlNodeIdShort adnl_id;
td::uint32 proto_version = 0;
td::uint64 capabilities = 0;
td::Clocks::Duration roundtrip = 0;
td::Clocks::Duration roundtrip_relax_at = 0;
double roundtrip = 0;
double roundtrip_relax_at = 0;
double roundtrip_weight = 0;
double unreliability = 0;
Neighbour(adnl::AdnlNodeIdShort adnl_id) : adnl_id(std::move(adnl_id)) {
}
void update_proto_version(const ton_api::tonNode_capabilities &q);
void query_success(td::Clocks::Duration t);
void query_success(double t);
void query_failed();
void update_roundtrip(td::Clocks::Duration t);
void update_roundtrip(double t);
static Neighbour zero;
};
@ -173,8 +173,8 @@ class FullNodeShardImpl : public FullNodeShard {
void ping_neighbours();
void reload_neighbours();
void got_neighbours(std::vector<adnl::AdnlNodeIdShort> res);
void update_neighbour_stats(adnl::AdnlNodeIdShort adnl_id, td::Clocks::Duration t, bool success);
void got_neighbour_capabilities(adnl::AdnlNodeIdShort adnl_id, td::Clocks::Duration t, td::BufferSlice data);
void update_neighbour_stats(adnl::AdnlNodeIdShort adnl_id, double t, bool success);
void got_neighbour_capabilities(adnl::AdnlNodeIdShort adnl_id, double t, td::BufferSlice data);
const Neighbour &choose_neighbour() const;
template <typename T>

View file

@ -227,7 +227,7 @@ void ValidatorManagerMasterchainReiniter::choose_masterchain_state() {
}
if (!p || ValidatorManager::is_persistent_state(h->unix_time(), p->unix_time())) {
auto ttl = ValidatorManager::persistent_state_ttl(h->unix_time());
td::Clocks::Duration time_to_download = 3600;
double time_to_download = 3600;
if (ttl > td::Clocks::system() + time_to_download) {
handle = h;
break;

View file

@ -27,8 +27,8 @@ namespace validator {
td::Ref<ValidatorManagerOptions> ValidatorManagerOptions::create(
BlockIdExt zero_block_id, BlockIdExt init_block_id,
std::function<bool(ShardIdFull, CatchainSeqno, ShardCheckMode)> check_shard, bool allow_blockchain_init,
td::ClocksBase::Duration sync_blocks_before, td::ClocksBase::Duration block_ttl, td::ClocksBase::Duration state_ttl,
td::ClocksBase::Duration archive_ttl, td::ClocksBase::Duration key_proof_ttl, bool initial_sync_disabled) {
double sync_blocks_before, double block_ttl, double state_ttl,
double archive_ttl, double key_proof_ttl, bool initial_sync_disabled) {
return td::make_ref<ValidatorManagerOptionsImpl>(zero_block_id, init_block_id, std::move(check_shard),
allow_blockchain_init, sync_blocks_before, block_ttl, state_ttl,
archive_ttl, key_proof_ttl, initial_sync_disabled);

View file

@ -41,19 +41,19 @@ struct ValidatorManagerOptionsImpl : public ValidatorManagerOptions {
bool allow_blockchain_init() const override {
return allow_blockchain_init_;
}
td::ClocksBase::Duration sync_blocks_before() const override {
double sync_blocks_before() const override {
return sync_blocks_before_;
}
td::ClocksBase::Duration block_ttl() const override {
double block_ttl() const override {
return block_ttl_;
}
td::ClocksBase::Duration state_ttl() const override {
double state_ttl() const override {
return state_ttl_;
}
td::ClocksBase::Duration archive_ttl() const override {
double archive_ttl() const override {
return archive_ttl_;
}
td::ClocksBase::Duration key_proof_ttl() const override {
double key_proof_ttl() const override {
return key_proof_ttl_;
}
bool initial_sync_disabled() const override {
@ -121,19 +121,19 @@ struct ValidatorManagerOptionsImpl : public ValidatorManagerOptions {
void set_allow_blockchain_init(bool value) override {
allow_blockchain_init_ = value;
}
void set_sync_blocks_before(td::ClocksBase::Duration value) override {
void set_sync_blocks_before(double value) override {
sync_blocks_before_ = value;
}
void set_block_ttl(td::ClocksBase::Duration value) override {
void set_block_ttl(double value) override {
block_ttl_ = value;
}
void set_state_ttl(td::ClocksBase::Duration value) override {
void set_state_ttl(double value) override {
state_ttl_ = value;
}
void set_archive_ttl(td::ClocksBase::Duration value) override {
void set_archive_ttl(double value) override {
archive_ttl_ = value;
}
void set_key_proof_ttl(td::ClocksBase::Duration value) override {
void set_key_proof_ttl(double value) override {
key_proof_ttl_ = value;
}
void set_initial_sync_disabled(bool value) override {
@ -161,9 +161,9 @@ struct ValidatorManagerOptionsImpl : public ValidatorManagerOptions {
ValidatorManagerOptionsImpl(BlockIdExt zero_block_id, BlockIdExt init_block_id,
std::function<bool(ShardIdFull, CatchainSeqno, ShardCheckMode)> check_shard,
bool allow_blockchain_init, td::ClocksBase::Duration sync_blocks_before,
td::ClocksBase::Duration block_ttl, td::ClocksBase::Duration state_ttl,
td::ClocksBase::Duration archive_ttl, td::ClocksBase::Duration key_proof_ttl,
bool allow_blockchain_init, double sync_blocks_before,
double block_ttl, double state_ttl,
double archive_ttl, double key_proof_ttl,
bool initial_sync_disabled)
: zero_block_id_(zero_block_id)
, init_block_id_(init_block_id)
@ -182,11 +182,11 @@ struct ValidatorManagerOptionsImpl : public ValidatorManagerOptions {
BlockIdExt init_block_id_;
std::function<bool(ShardIdFull, CatchainSeqno, ShardCheckMode)> check_shard_;
bool allow_blockchain_init_;
td::ClocksBase::Duration sync_blocks_before_;
td::ClocksBase::Duration block_ttl_;
td::ClocksBase::Duration state_ttl_;
td::ClocksBase::Duration archive_ttl_;
td::ClocksBase::Duration key_proof_ttl_;
double sync_blocks_before_;
double block_ttl_;
double state_ttl_;
double archive_ttl_;
double key_proof_ttl_;
bool initial_sync_disabled_;
std::vector<BlockIdExt> hardforks_;
std::set<CatchainSeqno> unsafe_catchains_;

View file

@ -53,11 +53,11 @@ struct ValidatorManagerOptions : public td::CntObject {
virtual bool need_monitor(ShardIdFull shard) const = 0;
virtual bool need_validate(ShardIdFull shard, CatchainSeqno cc_seqno) const = 0;
virtual bool allow_blockchain_init() const = 0;
virtual td::ClocksBase::Duration sync_blocks_before() const = 0;
virtual td::ClocksBase::Duration block_ttl() const = 0;
virtual td::ClocksBase::Duration state_ttl() const = 0;
virtual td::ClocksBase::Duration archive_ttl() const = 0;
virtual td::ClocksBase::Duration key_proof_ttl() const = 0;
virtual double sync_blocks_before() const = 0;
virtual double block_ttl() const = 0;
virtual double state_ttl() const = 0;
virtual double archive_ttl() const = 0;
virtual double key_proof_ttl() const = 0;
virtual bool initial_sync_disabled() const = 0;
virtual bool is_hardfork(BlockIdExt block_id) const = 0;
virtual td::uint32 get_vertical_seqno(BlockSeqno seqno) const = 0;
@ -78,11 +78,11 @@ struct ValidatorManagerOptions : public td::CntObject {
virtual void set_shard_check_function(
std::function<bool(ShardIdFull, CatchainSeqno, ShardCheckMode)> check_shard) = 0;
virtual void set_allow_blockchain_init(bool value) = 0;
virtual void set_sync_blocks_before(td::ClocksBase::Duration value) = 0;
virtual void set_block_ttl(td::ClocksBase::Duration value) = 0;
virtual void set_state_ttl(td::ClocksBase::Duration value) = 0;
virtual void set_archive_ttl(td::ClocksBase::Duration value) = 0;
virtual void set_key_proof_ttl(td::ClocksBase::Duration value) = 0;
virtual void set_sync_blocks_before(double value) = 0;
virtual void set_block_ttl(double value) = 0;
virtual void set_state_ttl(double value) = 0;
virtual void set_archive_ttl(double value) = 0;
virtual void set_key_proof_ttl(double value) = 0;
virtual void set_initial_sync_disabled(bool value) = 0;
virtual void set_hardforks(std::vector<BlockIdExt> hardforks) = 0;
virtual void add_unsafe_resync_catchain(CatchainSeqno seqno) = 0;
@ -94,9 +94,9 @@ struct ValidatorManagerOptions : public td::CntObject {
BlockIdExt zero_block_id, BlockIdExt init_block_id,
std::function<bool(ShardIdFull, CatchainSeqno, ShardCheckMode)> check_shard = [](ShardIdFull, CatchainSeqno,
ShardCheckMode) { return true; },
bool allow_blockchain_init = false, td::ClocksBase::Duration sync_blocks_before = 300,
td::ClocksBase::Duration block_ttl = 86400 * 7, td::ClocksBase::Duration state_ttl = 3600,
td::ClocksBase::Duration archive_ttl = 86400 * 365, td::ClocksBase::Duration key_proof_ttl = 86400 * 3650,
bool allow_blockchain_init = false, double sync_blocks_before = 300,
double block_ttl = 86400 * 7, double state_ttl = 3600,
double archive_ttl = 86400 * 365, double key_proof_ttl = 86400 * 3650,
bool initial_sync_disabled = false);
};