You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.0 KiB

/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <libp2p/injector/host_injector.hpp>
// implementations
#include <libp2p/basic/scheduler.hpp>
#include <libp2p/crypto/random_generator/boost_generator.hpp>
#include <libp2p/protocol/kademlia/config.hpp>
#include <libp2p/protocol/kademlia/impl/content_routing_table_impl.hpp>
#include <libp2p/protocol/kademlia/impl/kademlia_impl.hpp>
#include <libp2p/protocol/kademlia/impl/peer_routing_table_impl.hpp>
#include <libp2p/protocol/kademlia/impl/storage_backend_default.hpp>
#include <libp2p/protocol/kademlia/impl/storage_impl.hpp>
#include <libp2p/protocol/kademlia/impl/validator_default.hpp>
namespace libp2p::injector {
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
template <typename Injector>
std::shared_ptr<libp2p::protocol::kademlia::Kademlia> get_kademlia(
const Injector &injector) {
static auto initialized =
boost::optional<std::shared_ptr<libp2p::protocol::kademlia::Kademlia>>(
boost::none);
if (initialized) {
return initialized.value();
}
[[maybe_unused]] auto config =
injector.template create<protocol::kademlia::Config>();
[[maybe_unused]] auto host =
injector.template create<std::shared_ptr<Host>>();
[[maybe_unused]] auto storage =
injector
.template create<std::shared_ptr<protocol::kademlia::Storage>>();
[[maybe_unused]] auto table = injector.template create<
std::shared_ptr<protocol::kademlia::PeerRoutingTable>>();
[[maybe_unused]] auto content_routing_table = injector.template create<
std::shared_ptr<protocol::kademlia::ContentRoutingTable>>();
[[maybe_unused]] auto validator =
injector
.template create<std::shared_ptr<protocol::kademlia::Validator>>();
[[maybe_unused]] auto scheduler =
injector.template create<std::shared_ptr<basic::Scheduler>>();
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
[[maybe_unused]] auto random_generator = injector.template create<
std::shared_ptr<crypto::random::RandomGenerator>>();
[[maybe_unused]] auto bus =
injector.template create<std::shared_ptr<event::Bus>>();
initialized = std::make_shared<libp2p::protocol::kademlia::KademliaImpl>(
config,
std::move(host),
std::move(storage),
std::move(content_routing_table),
std::move(table),
std::move(validator),
std::move(scheduler),
std::move(bus),
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
std::move(random_generator));
return initialized.value();
}
template <
typename T,
typename C = std::decay_t<T>,
typename = std::enable_if<std::is_same_v<C, protocol::kademlia::Config>>>
inline auto useKademliaConfig(T &&c) {
return boost::di::bind<C>().to(
[c = std::forward<C>(c)](const auto &injector) mutable -> const C & {
static C instance = std::move(c);
return instance;
})[boost::di::override];
}
// clang-format off
template <typename InjectorConfig = BOOST_DI_CFG, typename... Ts>
auto makeKademliaInjector(Ts &&... args) {
namespace di = boost::di;
return di::make_injector<InjectorConfig>(
// clang-format off
di::bind<protocol::kademlia::Config>.to<protocol::kademlia::Config>(),
di::bind<protocol::kademlia::ContentRoutingTable>.to<protocol::kademlia::ContentRoutingTableImpl>(),
di::bind<protocol::kademlia::PeerRoutingTable>.to<protocol::kademlia::PeerRoutingTableImpl>(),
di::bind<protocol::kademlia::StorageBackend>.to<protocol::kademlia::StorageBackendDefault>(),
di::bind<protocol::kademlia::Storage>.to<protocol::kademlia::StorageImpl>(),
di::bind<protocol::kademlia::Validator>.to<protocol::kademlia::ValidatorDefault>(),
di::bind<protocol::kademlia::MessageObserver>.to<protocol::kademlia::KademliaImpl>(),
di::bind<protocol::kademlia::Kademlia>.to<protocol::kademlia::KademliaImpl>(),
// user-defined overrides...
std::forward<decltype(args)>(args)...
// clang-format on
);
}
} // namespace libp2p::injector