CatapultServer  v0.5.0.1 (Elephant)
ImportanceAwareNodeSelector.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/ionet/Node.h"
25 
26 namespace catapult {
27  namespace cache { class ImportanceView; }
28  namespace ionet { class NodeContainerView; }
29 }
30 
31 namespace catapult { namespace timesync {
32 
35  public:
36  using NodeSelector = std::function<ionet::NodeSet (extensions::WeightedCandidates&, uint64_t, size_t)>;
37 
38  public:
41  explicit ImportanceAwareNodeSelector(ionet::ServiceIdentifier serviceId, uint8_t maxNodes, Importance minImportance);
42 
46  ionet::ServiceIdentifier serviceId,
47  uint8_t maxNodes,
48  Importance minImportance,
49  const NodeSelector& selector);
50 
51  public:
54  const cache::ImportanceView& importanceView,
55  const ionet::NodeContainerView& nodeContainerView,
56  Height height) const;
57 
58  private:
59  std::pair<bool, Importance> isCandidate(
60  const cache::ImportanceView& importanceView,
61  const ionet::Node& node,
62  const ionet::NodeInfo& nodeInfo,
63  Height height) const;
64 
65  private:
67  uint8_t m_maxNodes;
70  };
71 }}
CumulativeImportance
Importance CumulativeImportance
Definition: ImportanceAwareNodeSelector.cpp:37
catapult::timesync::ImportanceAwareNodeSelector::NodeSelector
std::function< ionet::NodeSet(extensions::WeightedCandidates &, uint64_t, size_t)> NodeSelector
Definition: ImportanceAwareNodeSelector.h:36
catapult::ionet::Node::identityKey
const Key & identityKey() const
Gets the unique identifier (a public key).
Definition: Node.cpp:60
catapult::timesync::ImportanceAwareNodeSelector::m_maxNodes
uint8_t m_maxNodes
Definition: ImportanceAwareNodeSelector.h:67
catapult::extensions::WeightedCandidates
std::vector< WeightedCandidate > WeightedCandidates
Definition: NodeSelector.h:60
Local
ionet::Node Local
Definition: tools/network/main.cpp:42
catapult::timesync::ImportanceAwareNodeSelector::selectNodes
ionet::NodeSet selectNodes(const cache::ImportanceView &importanceView, const ionet::NodeContainerView &nodeContainerView, Height height) const
Selects nodes from nodeContainerView that have a minimum importance at height according to importance...
Definition: ImportanceAwareNodeSelector.cpp:73
NodeInfo.h
catapult::ionet::NodeInfo
Information about a node and its interactions.
Definition: NodeInfo.h:82
catapult::utils::BaseValue< uint32_t, ServiceIdentifier_tag >
catapult::extensions::SelectCandidatesBasedOnWeight
ionet::NodeSet SelectCandidatesBasedOnWeight(const WeightedCandidates &candidates, uint64_t totalCandidateWeight, size_t maxCandidates)
Definition: NodeSelector.cpp:143
catapult::ionet::NodeInfo::source
NodeSource source() const
Gets the node source.
Definition: NodeInfo.cpp:47
catapult::ionet::NodeContainerView
A read only view on top of node container.
Definition: NodeContainer.h:39
catapult::ionet::NodeInfo::getConnectionState
const ConnectionState * getConnectionState(ServiceIdentifier serviceId) const
Gets connection state for the service identified by serviceId or nullptr if no state exists.
Definition: NodeInfo.cpp:73
catapult::ionet::NodeSet
std::unordered_set< Node, NodeHasher > NodeSet
A set of nodes.
Definition: Node.h:128
Node.h
catapult::timesync::ImportanceAwareNodeSelector
A node selector that selects nodes according to the importance of the account used to boot the node.
Definition: ImportanceAwareNodeSelector.h:34
NodeContainer.h
NodeSelector.h
catapult::timesync::ImportanceAwareNodeSelector::ImportanceAwareNodeSelector
ImportanceAwareNodeSelector(ionet::ServiceIdentifier serviceId, uint8_t maxNodes, Importance minImportance)
Definition: ImportanceAwareNodeSelector.cpp:55
catapult::timesync::ImportanceAwareNodeSelector::m_selector
NodeSelector m_selector
Definition: ImportanceAwareNodeSelector.h:69
catapult::timesync::ImportanceAwareNodeSelector::isCandidate
std::pair< bool, Importance > isCandidate(const cache::ImportanceView &importanceView, const ionet::Node &node, const ionet::NodeInfo &nodeInfo, Height height) const
Definition: ImportanceAwareNodeSelector.cpp:84
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::timesync::ImportanceAwareNodeSelector::m_serviceId
ionet::ServiceIdentifier m_serviceId
Definition: ImportanceAwareNodeSelector.h:66
ImportanceView.h
ImportanceAwareNodeSelector.h
catapult::ionet::Node
A node in the catapult network.
Definition: Node.h:82
catapult::cache::ImportanceView
A view on top of an account state cache for retrieving importances.
Definition: ImportanceView.h:29
catapult::timesync::ImportanceAwareNodeSelector::m_minImportance
Importance m_minImportance
Definition: ImportanceAwareNodeSelector.h:68
catapult::cache::ImportanceView::getAccountImportanceOrDefault
Importance getAccountImportanceOrDefault(const Key &publicKey, Height height) const
Gets the importance for publicKey at height or a default importance if no importance is set.
Definition: ImportanceView.cpp:76
WeightedCandidates
extensions::WeightedCandidates WeightedCandidates
Definition: ImportanceAwareNodeSelector.cpp:36