/*
This file is part of TON Blockchain Library.
TON Blockchain Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
TON Blockchain Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see .
Copyright 2017-2019 Telegram Systems LLP
*/
#pragma once
#include "td/utils/buffer.h"
#include "td/utils/int_types.h"
#include "td/actor/actor.h"
#include "adnl/adnl.h"
#include "overlay-manager.h"
namespace ton {
namespace overlay {
class Overlay : public td::actor::Actor {
public:
using BroadcastHash = td::Bits256;
using BroadcastDataHash = td::Bits256;
using BroadcastPartHash = td::Bits256;
static td::actor::ActorOwn create(td::actor::ActorId keyring,
td::actor::ActorId adnl,
td::actor::ActorId manager,
td::actor::ActorId dht_node, adnl::AdnlNodeIdShort local_id,
OverlayIdFull overlay_id, std::unique_ptr callback,
OverlayPrivacyRules rules);
static td::actor::ActorOwn create(td::actor::ActorId keyring,
td::actor::ActorId adnl,
td::actor::ActorId manager,
td::actor::ActorId dht_node, adnl::AdnlNodeIdShort local_id,
OverlayIdFull overlay_id, std::vector nodes,
std::unique_ptr callback, OverlayPrivacyRules rules);
virtual void update_dht_node(td::actor::ActorId dht) = 0;
virtual void receive_message(adnl::AdnlNodeIdShort src, td::BufferSlice data) = 0;
virtual void receive_query(adnl::AdnlNodeIdShort src, td::BufferSlice data, td::Promise promise) = 0;
virtual void send_message_to_neighbours(td::BufferSlice data) = 0;
virtual void send_broadcast(PublicKeyHash send_as, td::uint32 flags, td::BufferSlice data) = 0;
virtual void send_broadcast_fec(PublicKeyHash send_as, td::uint32 flags, td::BufferSlice data) = 0;
virtual void print(td::StringBuilder &sb) = 0;
virtual void get_overlay_random_peers(td::uint32 max_peers,
td::Promise> promise) = 0;
virtual void add_certificate(PublicKeyHash key, std::shared_ptr) = 0;
virtual void set_privacy_rules(OverlayPrivacyRules rules) = 0;
virtual void receive_nodes_from_db(tl_object_ptr nodes) = 0;
//virtual void receive_broadcast(td::BufferSlice data) = 0;
//virtual void subscribe(std::unique_ptr callback) = 0;
};
} // namespace overlay
} // namespace ton