Ton

Форк
0
/
adnl-static-nodes.cpp 
55 строк · 1.7 Кб
1
/*
2
    This file is part of TON Blockchain Library.
3

4
    TON Blockchain Library is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU Lesser General Public License as published by
6
    the Free Software Foundation, either version 2 of the License, or
7
    (at your option) any later version.
8

9
    TON Blockchain Library is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU Lesser General Public License for more details.
13

14
    You should have received a copy of the GNU Lesser General Public License
15
    along with TON Blockchain Library.  If not, see <http://www.gnu.org/licenses/>.
16

17
    Copyright 2017-2020 Telegram Systems LLP
18
*/
19
#include "adnl-static-nodes.h"
20
#include "adnl-static-nodes.hpp"
21

22
#include "utils.hpp"
23

24
namespace ton {
25

26
namespace adnl {
27

28
void AdnlStaticNodesManagerImpl::add_node(AdnlNode node) {
29
  auto id_short = node.compute_short_id();
30
  VLOG(ADNL_INFO) << "[staticnodes] adding static node " << id_short;
31

32
  nodes_.emplace(id_short, std::move(node));
33
}
34

35
void AdnlStaticNodesManagerImpl::del_node(AdnlNodeIdShort id) {
36
  nodes_.erase(id);
37
}
38

39
td::Result<AdnlNode> AdnlStaticNodesManagerImpl::get_node(AdnlNodeIdShort id) {
40
  auto it = nodes_.find(id);
41
  if (it == nodes_.end()) {
42
    return td::Status::Error(ErrorCode::notready, "static node not found");
43
  }
44

45
  return it->second;
46
}
47

48
td::actor::ActorOwn<AdnlStaticNodesManager> AdnlStaticNodesManager::create() {
49
  auto X = td::actor::create_actor<AdnlStaticNodesManagerImpl>("staticnodesmanager");
50
  return td::actor::ActorOwn<AdnlStaticNodesManager>(std::move(X));
51
}
52

53
}  // namespace adnl
54

55
}  // namespace ton
56

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.