CatapultServer  v0.5.0.1 (Elephant)
RemoteNodeSynchronizer.h
Go to the documentation of this file.
1 
21 #pragma once
24 #include <functional>
25 
26 namespace catapult { namespace chain {
27 
29  template<typename TRemoteApi>
30  using RemoteNodeSynchronizer = std::function<thread::future<ionet::NodeInteractionResultCode> (const TRemoteApi&)>;
31 
33  template<typename TSynchronizer>
35  const std::shared_ptr<TSynchronizer>& pSynchronizer) {
36  return [pSynchronizer](const auto& remoteApi) {
37  // pSynchronizer is captured in the second lambda to compose, which extends its lifetime until
38  // the async operation is complete
39  return thread::compose(pSynchronizer->operator()(remoteApi), [pSynchronizer](auto&& future) {
40  return std::move(future);
41  });
42  };
43  }
44 }}
catapult::chain::RemoteNodeSynchronizer
std::function< thread::future< ionet::NodeInteractionResultCode >(const TRemoteApi &)> RemoteNodeSynchronizer
Function signature for synchronizing with a remote node.
Definition: RemoteNodeSynchronizer.h:30
FutureUtils.h
catapult::thread::compose
auto compose(future< TSeed > &&startFuture, TCreateNextFuture createNextFuture)
Definition: FutureUtils.h:102
NodeInteractionResultCode.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::chain::CreateRemoteNodeSynchronizer
RemoteNodeSynchronizer< typename TSynchronizer::RemoteApiType > CreateRemoteNodeSynchronizer(const std::shared_ptr< TSynchronizer > &pSynchronizer)
Creates a remote node synchronizer around pSynchronizer.
Definition: RemoteNodeSynchronizer.h:34