Skip to content

Commit

Permalink
Adopt latest libp2p
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
  • Loading branch information
Igor Egorov committed Aug 10, 2021
1 parent 689320c commit 0d0fdb7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ hunter_config(

hunter_config(
libp2p
URL https://github.com/libp2p/cpp-libp2p/archive/9e3d90f3fe43c23ba8980e3498584a7b15507c5d.tar.gz
SHA1 ca417cbe83acf056a70445cf521b5b9421cc9644
URL https://github.com/igor-egorov/cpp-libp2p/archive/7c9d83bf0760a5f653d86ddbb00645414c61d4fc.tar.gz
SHA1 f4408541230f4953678d1871096786cba2f5fcef
CMAKE_ARGS TESTING=OFF EXAMPLES=OFF EXPOSE_MOCKS=ON
KEEP_PACKAGE_SOURCES
)
Expand Down
6 changes: 3 additions & 3 deletions core/injector/application_injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ namespace {
injector.template create<libp2p::Host &>(),
injector.template create<sptr<libp2p::protocol::Identify>>(),
injector.template create<sptr<libp2p::protocol::kademlia::Kademlia>>(),
injector.template create<sptr<libp2p::protocol::Scheduler>>(),
injector.template create<sptr<libp2p::basic::Scheduler>>(),
injector.template create<sptr<network::StreamEngine>>(),
injector.template create<const application::AppConfiguration &>(),
injector.template create<sptr<clock::SteadyClock>>(),
Expand Down Expand Up @@ -768,7 +768,7 @@ namespace {

template <typename... Ts>
auto makeApplicationInjector(const application::AppConfiguration &config,
Ts &&... args) {
Ts &&...args) {
// default values for configurations
api::RpcThreadPool::Configuration rpc_thread_pool_config{};
api::HttpSession::Configuration http_config{};
Expand Down Expand Up @@ -1198,7 +1198,7 @@ namespace {

template <typename... Ts>
auto makeKagomeNodeInjector(const application::AppConfiguration &app_config,
Ts &&... args) {
Ts &&...args) {
using namespace boost; // NOLINT;

return di::make_injector(
Expand Down
9 changes: 5 additions & 4 deletions core/network/impl/peer_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace kagome::network {
libp2p::Host &host,
std::shared_ptr<libp2p::protocol::Identify> identify,
std::shared_ptr<libp2p::protocol::kademlia::Kademlia> kademlia,
std::shared_ptr<libp2p::protocol::Scheduler> scheduler,
std::shared_ptr<libp2p::basic::Scheduler> scheduler,
std::shared_ptr<StreamEngine> stream_engine,
const application::AppConfiguration &app_config,
std::shared_ptr<clock::SteadyClock> clock,
Expand Down Expand Up @@ -255,13 +255,14 @@ namespace kagome::network {

const auto aligning_period = app_config_.peeringConfig().aligningPeriod;

align_timer_ = scheduler_->schedule(
libp2p::protocol::scheduler::toTicks(aligning_period),
align_timer_ = scheduler_->scheduleWithHandle(
[wp = weak_from_this()] {
if (auto self = wp.lock()) {
self->align();
}
});
},
aligning_period); // automatically converts from seconds to
// milliseconds
SL_DEBUG(log_, "Active peers = {}", active_peers_.size());
}

Expand Down
6 changes: 3 additions & 3 deletions core/network/impl/peer_manager_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace kagome::network {
libp2p::Host &host,
std::shared_ptr<libp2p::protocol::Identify> identify,
std::shared_ptr<libp2p::protocol::kademlia::Kademlia> kademlia,
std::shared_ptr<libp2p::protocol::Scheduler> scheduler,
std::shared_ptr<libp2p::basic::Scheduler> scheduler,
std::shared_ptr<StreamEngine> stream_engine,
const application::AppConfiguration &app_config,
std::shared_ptr<clock::SteadyClock> clock,
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace kagome::network {
libp2p::Host &host_;
std::shared_ptr<libp2p::protocol::Identify> identify_;
std::shared_ptr<libp2p::protocol::kademlia::Kademlia> kademlia_;
std::shared_ptr<libp2p::protocol::Scheduler> scheduler_;
std::shared_ptr<libp2p::basic::Scheduler> scheduler_;
std::shared_ptr<StreamEngine> stream_engine_;
const application::AppConfiguration &app_config_;
std::shared_ptr<clock::SteadyClock> clock_;
Expand All @@ -242,7 +242,7 @@ namespace kagome::network {
};

std::map<PeerId, ActivePeerData> active_peers_;
libp2p::protocol::scheduler::Handle align_timer_;
libp2p::basic::Scheduler::Handle align_timer_;
std::set<PeerId> recently_active_peers_;

log::Logger log_;
Expand Down

0 comments on commit 0d0fdb7

Please sign in to comment.