CatapultServer  v0.5.0.1 (Elephant)
NodePingRequestor.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NodePingUtils.h"
25 
26 namespace catapult { namespace nodediscovery {
27 
30  public:
33  : m_networkIdentifier(networkIdentifier)
34  {}
35 
36  public:
38  bool isResponseCompatible(const ionet::Node& requestNode, const ionet::Node& responseNode) const {
39  if (IsNodeCompatible(responseNode, m_networkIdentifier, requestNode.identityKey()))
40  return true;
41 
42  CATAPULT_LOG(warning) << "rejecting incompatible partner node '" << responseNode << "'";
43  return false;
44  }
45 
46  private:
48  };
49 
53 
54  static constexpr auto Friendly_Name = "ping";
55 
57  return api::CreateRemoteNodeApi(packetIo)->nodeInfo();
58  }
59  };
60 
63 
66  std::shared_ptr<NodePingRequestor> CreateNodePingRequestor(
67  const std::shared_ptr<thread::IoThreadPool>& pPool,
68  const crypto::KeyPair& keyPair,
69  const net::ConnectionSettings& settings,
70  model::NetworkIdentifier networkIdentifier);
71 }}
NodePingRequestor.h
catapult::nodediscovery::NodePingResponseCompatibilityChecker::isResponseCompatible
bool isResponseCompatible(const ionet::Node &requestNode, const ionet::Node &responseNode) const
Returns true if requestNode and responseNode are compatible nodes.
Definition: NodePingRequestor.h:38
catapult::api::CreateRemoteNodeApi
std::unique_ptr< RemoteNodeApi > CreateRemoteNodeApi(ionet::PacketIo &io)
Creates a node api for interacting with a remote node with the specified io.
Definition: RemoteNodeApi.cpp:87
catapult::nodediscovery::NodePingResponseCompatibilityChecker
Node ping response compatibility checker.
Definition: NodePingRequestor.h:29
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
catapult::net::ConnectionSettings
Settings used to configure connections.
Definition: ConnectionSettings.h:31
catapult::nodediscovery::NodePingRequestPolicy::CreateFuture
static thread::future< ResponseType > CreateFuture(ionet::PacketIo &packetIo)
Definition: NodePingRequestor.h:56
catapult::ionet::Node::identityKey
const Key & identityKey() const
Gets the unique identifier (a public key).
Definition: Node.cpp:60
colorPrint.warning
def warning(*args)
Definition: colorPrint.py:10
catapult::nodediscovery::IsNodeCompatible
bool IsNodeCompatible(const ionet::Node &node, model::NetworkIdentifier networkIdentifier, const Key &identityKey)
Determines if node is compatible with expected network (networkIdentifier) and identity (identityKey)...
Definition: NodePingUtils.cpp:52
catapult::net::BriefServerRequestor
Definition: BriefServerRequestor.h:48
catapult::nodediscovery::NodePingResponseCompatibilityChecker::m_networkIdentifier
model::NetworkIdentifier m_networkIdentifier
Definition: NodePingRequestor.h:47
BriefServerRequestor.h
RemoteNodeApi.h
catapult::ionet::PacketIo
An interface for reading and writing packets.
Definition: PacketIo.h:31
catapult::crypto::KeyPair
Represents a pair of private key with associated public key.
Definition: KeyPair.h:33
catapult::nodediscovery::CreateNodePingRequestor
std::shared_ptr< NodePingRequestor > CreateNodePingRequestor(const std::shared_ptr< thread::IoThreadPool > &pPool, const crypto::KeyPair &keyPair, const net::ConnectionSettings &settings, model::NetworkIdentifier networkIdentifier)
Definition: NodePingRequestor.cpp:25
catapult::thread::future
Provides a way to access the result of an asynchronous operation.
Definition: Future.h:29
catapult::model::NetworkIdentifier
NetworkIdentifier
Possible network identifiers.
Definition: NetworkInfo.h:45
catapult::nodediscovery::NodePingRequestPolicy::Friendly_Name
static constexpr auto Friendly_Name
Definition: NodePingRequestor.h:54
catapult::nodediscovery::NodePingResponseCompatibilityChecker::NodePingResponseCompatibilityChecker
NodePingResponseCompatibilityChecker(model::NetworkIdentifier networkIdentifier)
Creates a checker around networkIdentifier.
Definition: NodePingRequestor.h:32
Node
ionet::Node Node
Definition: PacketWriters.cpp:45
catapult
Definition: AddressExtractionExtension.cpp:28
NodePingUtils.h
catapult::ionet::Node
A node in the catapult network.
Definition: Node.h:82
catapult::nodediscovery::NodePingRequestPolicy
Node ping request policy.
Definition: NodePingRequestor.h:51