CatapultServer  v0.5.0.1 (Elephant)
Node.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NodeRoles.h"
24 #include "catapult/utils/Hashers.h"
25 #include <unordered_set>
26 
27 namespace catapult { namespace ionet {
28 
29  struct NodeVersion_tag {};
30 
33 
35  struct NodeEndpoint {
37  std::string Host;
38 
40  unsigned short Port;
41  };
42 
44  struct NodeMetadata {
45  public:
48  {}
49 
51  explicit NodeMetadata(model::NetworkIdentifier networkIdentifier) : NodeMetadata(networkIdentifier, "")
52  {}
53 
55  NodeMetadata(model::NetworkIdentifier networkIdentifier, const std::string& name)
56  : NodeMetadata(networkIdentifier, name, NodeVersion(), NodeRoles::None)
57  {}
58 
60  NodeMetadata(model::NetworkIdentifier networkIdentifier, const std::string& name, NodeVersion version, NodeRoles roles)
61  : NetworkIdentifier(networkIdentifier)
62  , Name(name)
63  , Version(version)
64  , Roles(roles)
65  {}
66 
67  public:
70 
72  std::string Name;
73 
76 
79  };
80 
82  class Node {
83  public:
85  Node();
86 
89 
90  public:
92  const Key& identityKey() const;
93 
95  const NodeEndpoint& endpoint() const;
96 
98  const NodeMetadata& metadata() const;
99 
100  public:
102  bool operator==(const Node& rhs) const;
103 
105  bool operator!=(const Node& rhs) const;
106 
107  public:
109  friend std::ostream& operator<<(std::ostream& out, const Node& node);
110 
111  private:
115 
116  std::string m_printableName;
117  };
118 
120  struct NodeHasher {
122  size_t operator()(const Node& node) const {
123  return utils::ArrayHasher<Key>()(node.identityKey());
124  }
125  };
126 
128  using NodeSet = std::unordered_set<Node, NodeHasher>;
129 }}
catapult::ionet::NodeEndpoint
A node's publicly accessible endpoint.
Definition: Node.h:35
catapult::validators::DEFINE_STATEFUL_VALIDATOR
DEFINE_STATEFUL_VALIDATOR(EligibleHarvester, [](const auto &notification, const auto &context) { cache::ImportanceView view(context.Cache.template sub< cache::AccountStateCache >());return view.canHarvest(notification.Signer, context.Height) ? ValidationResult::Success :Failure_Core_Block_Harvester_Ineligible;})
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
m_newBlockSink
NewBlockSink m_newBlockSink
Definition: NewBlockConsumer.cpp:66
catapult::model::MakeTransactionInfo
TransactionInfo MakeTransactionInfo(const std::shared_ptr< const Transaction > &pTransaction, const TransactionElement &transactionElement)
Makes a transaction info by merging pTransaction and transactionElement.
Definition: Elements.cpp:103
catapult::consumers::CompleteSuccess
constexpr disruptor::ConsumerResult CompleteSuccess()
Creates a completed success consumer result.
Definition: ConsumerResultFactory.h:39
catapult::ionet::NodeHasher::operator()
size_t operator()(const Node &node) const
Hashes node.
Definition: Node.h:122
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::ionet::NodeMetadata::Name
std::string Name
Friendly name (optional).
Definition: Node.h:72
catapult::model::EntityRange::ExtractEntitiesFromRange
static std::vector< std::shared_ptr< TEntity > > ExtractEntitiesFromRange(EntityRange &&range)
Definition: EntityRange.h:470
m_sinkSourceMask
InputSource m_sinkSourceMask
Definition: NewBlockConsumer.cpp:67
catapult::ionet::Node::identityKey
const Key & identityKey() const
Gets the unique identifier (a public key).
Definition: Node.cpp:60
m_newTransactionsSink
NewTransactionsSink m_newTransactionsSink
Definition: NewTransactionsConsumer.cpp:75
ValidatorContext.h
catapult::disruptor::InputSource
InputSource
Possible consumer input sources.
Definition: InputSource.h:42
catapult::validators::Notification
model::AccountAddressNotification Notification
Definition: AddressValidator.cpp:27
NodeRoles.h
catapult::ionet::Node::Node
Node()
Creates a default node.
Definition: Node.cpp:48
BlockConsumers.h
catapult::ionet::NodeMetadata::NodeMetadata
NodeMetadata()
Creates default metadata.
Definition: Node.h:47
catapult::ionet::Node::operator==
bool operator==(const Node &rhs) const
Returns true if this node is equal to rhs.
Definition: Node.cpp:72
catapult::utils::to_underlying_type
constexpr std::underlying_type_t< TEnum > to_underlying_type(TEnum value)
Converts a strongly typed enumeration value to its underlying integral value.
Definition: Casting.h:37
catapult::utils::BaseValue< uint32_t, NodeVersion_tag >
ConsumerResultFactory.h
catapult::ionet::NodeMetadata::NodeMetadata
NodeMetadata(model::NetworkIdentifier networkIdentifier, const std::string &name, NodeVersion version, NodeRoles roles)
Creates metadata for a node with name, version and roles in the network identified by networkIdentifi...
Definition: Node.h:60
Validators.h
catapult::ionet::NodeMetadata::NodeMetadata
NodeMetadata(model::NetworkIdentifier networkIdentifier, const std::string &name)
Creates metadata for a node with name in the network identified by networkIdentifier.
Definition: Node.h:55
catapult::consumers::CreateNewBlockConsumer
disruptor::DisruptorConsumer CreateNewBlockConsumer(const NewBlockSink &newBlockSink, disruptor::InputSource sinkSourceMask)
catapult::ionet::NodeMetadata::NodeMetadata
NodeMetadata(model::NetworkIdentifier networkIdentifier)
Creates metadata for a node in the network identified by networkIdentifier.
Definition: Node.h:51
NetworkInfo.h
catapult::ionet::NodeHasher
Hasher object for a node.
Definition: Node.h:120
catapult::validators::MAKE_STATELESS_VALIDATOR
for(const auto &name :reservedRootNamespaceNames) reservedRootIds.emplace(model return MAKE_STATELESS_VALIDATOR(NamespaceName,([maxNameSize, reservedRootIds](const auto &notification) { if(maxNameSize< notification.NameSize||!model::IsValidName(notification.NamePtr, notification.NameSize)) return Failure_Namespace_Invalid_Name;auto name=utils::RawString(reinterpret_cast< const char * >(notification.NamePtr), notification.NameSize);if(notification.NamespaceId !=model::GenerateNamespaceId(notification.ParentId, name)) return Failure_Namespace_Name_Id_Mismatch;auto namespaceId=Namespace_Base_Id==notification.ParentId ? notification.NamespaceId :notification.ParentId;if(reservedRootIds.cend() !=reservedRootIds.find(namespaceId)) return Failure_Namespace_Root_Name_Reserved;return ValidationResult::Success;}))
Definition: NamespaceNameValidator.cpp:36
catapult::ionet::NodeRoles::None
No roles.
catapult::ionet::Node::m_printableName
std::string m_printableName
Definition: Node.h:116
catapult::ionet::NodeVersion_tag
Definition: Node.h:29
VerifiableEntity.h
catapult::ionet::NodeSet
std::unordered_set< Node, NodeHasher > NodeSet
A set of nodes.
Definition: Node.h:128
catapult::ionet::Node::operator!=
bool operator!=(const Node &rhs) const
Returns true if this node is not equal to rhs.
Definition: Node.cpp:76
catapult::consumers::NewTransactionsSink
consumer< TransactionInfos && > NewTransactionsSink
Prototype for a function that is called with new transactions.
Definition: TransactionConsumers.h:55
catapult::ionet::NodeRoles
NodeRoles
A node's role.
Definition: NodeRoles.h:28
Node.h
Address.h
m_endpoint
boost::asio::ip::tcp::endpoint m_endpoint
Definition: PacketSocket.cpp:480
catapult::ionet::Node::m_identityKey
Key m_identityKey
Definition: Node.h:112
catapult::consumers::TransactionInfos
std::vector< model::TransactionInfo > TransactionInfos
Container for transactions infos.
Definition: InputUtils.h:48
catapult::model::PublicKeyToAddress
Address PublicKeyToAddress(const Key &publicKey, NetworkIdentifier networkIdentifier)
Creates an address from a public key (publicKey) for the network identified by networkIdentifier.
Definition: Address.cpp:50
catapult::model::AddressToString
std::string AddressToString(const Address &address)
Creates an encoded address from an address.
Definition: Address.cpp:38
catapult::ionet::Node::operator<<
friend std::ostream & operator<<(std::ostream &out, const Node &node)
Insertion operator for outputting node to out.
Definition: Node.cpp:80
catapult::consumers::Abort
constexpr disruptor::ConsumerResult Abort(validators::ValidationResult validationResult)
Creates an aborted consumer result around validationResult.
Definition: ConsumerResultFactory.h:34
catapult::ionet::operator<<
std::ostream & operator<<(std::ostream &out, ConnectionSecurityMode value)
Insertion operator for outputting value to out.
AccountStateCache.h
catapult::model::NetworkIdentifier
NetworkIdentifier
Possible network identifiers.
Definition: NetworkInfo.h:45
catapult::ionet::NodeMetadata
Additional node information.
Definition: Node.h:44
catapult::ionet::Node::m_endpoint
NodeEndpoint m_endpoint
Definition: Node.h:113
catapult::ionet::Node::endpoint
const NodeEndpoint & endpoint() const
Gets the endpoint.
Definition: Node.cpp:64
catapult::ionet::Node::metadata
const NodeMetadata & metadata() const
Gets tne metadata.
Definition: Node.cpp:68
catapult::validators::ResultSeverity::Failure
Validation result is failure.
catapult::ionet::NodeEndpoint::Host
std::string Host
Host.
Definition: Node.h:37
catapult::validators::ValidationResult::Success
Validation succeeded.
catapult::ionet::NodeMetadata::Roles
NodeRoles Roles
Role(s).
Definition: Node.h:78
catapult::state::AccountType::Remote_Unlinked
Account is a remote harvester eligible account that is unlinked.
catapult::disruptor::ConsumerResultSeverity::Failure
Failure result.
catapult::validators::DECLARE_STATELESS_VALIDATOR
DECLARE_STATELESS_VALIDATOR(MaxTransactions, Notification)(uint32_t maxTransactions)
Definition: MaxTransactionsValidator.cpp:27
Casting.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::consumers::CreateNewTransactionsConsumer
disruptor::DisruptorConsumer CreateNewTransactionsConsumer(const NewTransactionsSink &newTransactionsSink)
Definition: NewTransactionsConsumer.cpp:79
catapult::consumers::CompleteNeutral
constexpr disruptor::ConsumerResult CompleteNeutral()
Creates a completed neutral consumer result.
Definition: ConsumerResultFactory.h:44
catapult::model::AccountAddressNotification
Notification of use of an account address.
Definition: Notifications.h:57
Hashers.h
catapult::consumers::NewBlockSink
consumer< const std::shared_ptr< const model::Block > & > NewBlockSink
Prototype for a function that is called with a new block.
Definition: BlockConsumers.h:84
catapult::utils::ByteArray< Key_Size, Key_tag >
catapult::ionet::Node::m_metadata
NodeMetadata m_metadata
Definition: Node.h:114
catapult::disruptor::DisruptorConsumer
DisruptorConsumerT< ConsumerInput > DisruptorConsumer
A disruptor consumer function.
Definition: DisruptorConsumer.h:32
catapult::ionet::Node
A node in the catapult network.
Definition: Node.h:82
catapult::ionet::NodeMetadata::NetworkIdentifier
model::NetworkIdentifier NetworkIdentifier
Network identifier.
Definition: Node.h:69
catapult::Key
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
catapult::ionet::NodeMetadata::Version
NodeVersion Version
Version.
Definition: Node.h:75
catapult::disruptor::ConsumerResultSeverity::Success
Success result.
catapult::utils::ArrayHasher
Definition: Hashers.h:32
catapult::ionet::NodeEndpoint::Port
unsigned short Port
Port.
Definition: Node.h:40
catapult::consumers::Continue
constexpr disruptor::ConsumerResult Continue()
Creates a continuation consumer result.
Definition: ConsumerResultFactory.h:29
TransactionConsumers.h