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

Shardchain validation without monitoring shardchains

This commit is contained in:
SpyCheese 2022-07-18 18:35:06 +03:00
parent bdfca7afef
commit 996c23e506
22 changed files with 210 additions and 88 deletions

View file

@ -98,6 +98,15 @@ void OverlayManager::create_public_overlay(adnl::AdnlNodeIdShort local_id, Overl
std::move(callback), std::move(rules), scope));
}
void OverlayManager::create_public_overlay_no_subscribe(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
OverlayPrivacyRules rules, td::string scope) {
CHECK(!dht_node_.empty());
auto id = overlay_id.compute_short_id();
register_overlay(local_id, id,
Overlay::create(keyring_, adnl_, actor_id(this), dht_node_, local_id, std::move(overlay_id), nullptr,
std::move(rules), scope));
}
void OverlayManager::create_private_overlay(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
std::vector<adnl::AdnlNodeIdShort> nodes,
std::unique_ptr<Callback> callback, OverlayPrivacyRules rules) {

View file

@ -52,6 +52,8 @@ class OverlayManager : public Overlays {
void create_public_overlay(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
std::unique_ptr<Callback> callback, OverlayPrivacyRules rules, td::string scope) override;
void create_public_overlay_no_subscribe(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
OverlayPrivacyRules rules, td::string scope) override;
void create_private_overlay(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
std::vector<adnl::AdnlNodeIdShort> nodes, std::unique_ptr<Callback> callback,
OverlayPrivacyRules rules) override;

View file

@ -149,6 +149,9 @@ void OverlayImpl::receive_query(adnl::AdnlNodeIdShort src, td::BufferSlice data,
if (R.is_error()) {
// allow custom query to be here
if (!subscribed()) {
return;
}
callback_->receive_query(src, overlay_id_, std::move(data), std::move(promise));
return;
}
@ -225,6 +228,9 @@ void OverlayImpl::receive_message(adnl::AdnlNodeIdShort src, td::BufferSlice dat
}
auto X = fetch_tl_object<ton_api::overlay_Broadcast>(data.clone(), true);
if (X.is_error()) {
if (!subscribed()) {
return;
}
VLOG(OVERLAY_DEBUG) << this << ": received custom message";
callback_->receive_message(src, overlay_id_, std::move(data));
return;
@ -268,7 +274,7 @@ void OverlayImpl::alarm() {
}
if (public_) {
if (peers_.size() > 0) {
if (peers_.size() > 0 && subscribed()) {
auto P = get_random_peer();
if (P) {
send_random_peers(P->get_id(), {});
@ -336,7 +342,7 @@ void OverlayImpl::receive_dht_nodes(td::Result<dht::DhtValue> res, bool dummy) {
}
void OverlayImpl::update_dht_nodes(OverlayNode node) {
if (!public_) {
if (!public_ || !subscribed()) {
return;
}
@ -497,6 +503,9 @@ void OverlayImpl::send_new_fec_broadcast_part(PublicKeyHash local_id, Overlay::B
}
void OverlayImpl::deliver_broadcast(PublicKeyHash source, td::BufferSlice data) {
if (!subscribed()) {
return;
}
callback_->receive_broadcast(source, overlay_id_, std::move(data));
}
@ -569,6 +578,9 @@ void OverlayImpl::set_privacy_rules(OverlayPrivacyRules rules) {
}
void OverlayImpl::check_broadcast(PublicKeyHash src, td::BufferSlice data, td::Promise<td::Unit> promise) {
if (!subscribed()) {
return;
}
callback_->check_broadcast(src, overlay_id_, std::move(data), std::move(promise));
}

View file

@ -251,8 +251,15 @@ class OverlayImpl : public Overlay {
}
private:
bool subscribed() const {
return (bool)callback_;
}
template <class T>
void process_query(adnl::AdnlNodeIdShort src, T &query, td::Promise<td::BufferSlice> promise) {
if (!subscribed()) {
return;
}
callback_->receive_query(src, overlay_id_, serialize_tl_object(&query, true), std::move(promise));
}

View file

@ -194,6 +194,8 @@ class Overlays : public td::actor::Actor {
virtual void create_public_overlay(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
std::unique_ptr<Callback> callback, OverlayPrivacyRules rules, td::string scope) = 0;
virtual void create_public_overlay_no_subscribe(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
OverlayPrivacyRules rules, td::string scope) = 0;
virtual void create_private_overlay(adnl::AdnlNodeIdShort local_id, OverlayIdFull overlay_id,
std::vector<adnl::AdnlNodeIdShort> nodes, std::unique_ptr<Callback> callback,
OverlayPrivacyRules rules) = 0;