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

fullnode: support for TCP master/slave replication

This commit is contained in:
ton 2019-09-19 23:15:32 +04:00
parent bfa166d66c
commit f40822b58a
50 changed files with 1109 additions and 244 deletions

View file

@ -36,7 +36,8 @@ GetNextKeyBlocks::GetNextKeyBlocks(BlockIdExt block_id, td::uint32 limit, adnl::
td::uint32 priority, td::Timestamp timeout,
td::actor::ActorId<ValidatorManagerInterface> validator_manager,
td::actor::ActorId<rldp::Rldp> rldp, td::actor::ActorId<overlay::Overlays> overlays,
td::actor::ActorId<adnl::Adnl> adnl, td::Promise<std::vector<BlockIdExt>> promise)
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<adnl::AdnlExtClient> client,
td::Promise<std::vector<BlockIdExt>> promise)
: block_id_(block_id)
, limit_(limit)
, local_id_(local_id)
@ -48,6 +49,7 @@ GetNextKeyBlocks::GetNextKeyBlocks(BlockIdExt block_id, td::uint32 limit, adnl::
, rldp_(rldp)
, overlays_(overlays)
, adnl_(adnl)
, client_(client)
, promise_(std::move(promise)) {
}
@ -97,7 +99,7 @@ void GetNextKeyBlocks::start_up() {
void GetNextKeyBlocks::got_download_token(std::unique_ptr<DownloadToken> token) {
token_ = std::move(token);
if (download_from_.is_zero()) {
if (download_from_.is_zero() && client_.empty()) {
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<std::vector<adnl::AdnlNodeIdShort>> R) {
if (R.is_error()) {
td::actor::send_closure(SelfId, &GetNextKeyBlocks::abort_query, R.move_as_error());
@ -130,11 +132,15 @@ void GetNextKeyBlocks::got_node_to_download(adnl::AdnlNodeIdShort node) {
td::actor::send_closure(SelfId, &GetNextKeyBlocks::got_result, R.move_as_ok());
}
});
td::actor::send_closure(
overlays_, &overlay::Overlays::send_query, download_from_, local_id_, overlay_id_, "get_prepare", std::move(P),
td::Timestamp::in(1.0),
create_serialize_tl_object<ton_api::tonNode_getNextKeyBlockIds>(create_tl_block_id(block_id_), limit_));
auto query = create_serialize_tl_object<ton_api::tonNode_getNextKeyBlockIds>(create_tl_block_id(block_id_), limit_);
if (client_.empty()) {
td::actor::send_closure(overlays_, &overlay::Overlays::send_query, download_from_, local_id_, overlay_id_,
"get_prepare", std::move(P), td::Timestamp::in(1.0), std::move(query));
} else {
td::actor::send_closure(client_, &adnl::AdnlExtClient::send_query, "get_prepare",
create_serialize_tl_object_suffix<ton_api::tonNode_query>(std::move(query)),
td::Timestamp::in(1.0), std::move(P));
}
}
void GetNextKeyBlocks::got_result(td::BufferSlice data) {
@ -173,7 +179,8 @@ void GetNextKeyBlocks::download_next_proof() {
});
td::actor::create_actor<DownloadProof>("downloadproofreq", block_id, false, local_id_, overlay_id_, download_from_,
priority_, timeout_, validator_manager_, rldp_, overlays_, adnl_, std::move(P))
priority_, timeout_, validator_manager_, rldp_, overlays_, adnl_, client_,
std::move(P))
.release();
}