Ton
1/*
2This file is part of TON Blockchain Library.
3
4TON Blockchain Library is free software: you can redistribute it and/or modify
5it under the terms of the GNU Lesser General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9TON Blockchain Library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
16
17Copyright 2017-2020 Telegram Systems LLP
18*/
19#include "adnl-static-nodes.h"20#include "adnl-static-nodes.hpp"21
22#include "utils.hpp"23
24namespace ton {25
26namespace adnl {27
28void AdnlStaticNodesManagerImpl::add_node(AdnlNode node) {29auto id_short = node.compute_short_id();30VLOG(ADNL_INFO) << "[staticnodes] adding static node " << id_short;31
32nodes_.emplace(id_short, std::move(node));33}
34
35void AdnlStaticNodesManagerImpl::del_node(AdnlNodeIdShort id) {36nodes_.erase(id);37}
38
39td::Result<AdnlNode> AdnlStaticNodesManagerImpl::get_node(AdnlNodeIdShort id) {40auto it = nodes_.find(id);41if (it == nodes_.end()) {42return td::Status::Error(ErrorCode::notready, "static node not found");43}44
45return it->second;46}
47
48td::actor::ActorOwn<AdnlStaticNodesManager> AdnlStaticNodesManager::create() {49auto X = td::actor::create_actor<AdnlStaticNodesManagerImpl>("staticnodesmanager");50return td::actor::ActorOwn<AdnlStaticNodesManager>(std::move(X));51}
52
53} // namespace adnl54
55} // namespace ton56