CatapultServer  v0.5.0.1 (Elephant)
PacketWriters.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ConnectionContainer.h"
23 #include "ConnectionSettings.h"
24 #include "PacketIoPicker.h"
25 #include "PeerConnectResult.h"
26 #include <memory>
27 
28 namespace catapult {
29  namespace crypto { class KeyPair; }
30  namespace ionet {
31  class Node;
32  class PacketSocket;
33  }
34  namespace net { struct Packet; }
35  namespace thread { class IoThreadPool; }
36 }
37 
38 namespace catapult { namespace net {
39 
42  public:
44 
45  public:
47  virtual size_t numActiveWriters() const = 0;
48 
51  virtual size_t numAvailableWriters() const = 0;
52 
53  public:
55  virtual void broadcast(const ionet::PacketPayload& payload) = 0;
56 
57  public:
59  virtual void connect(const ionet::Node& node, const ConnectCallback& callback) = 0;
60 
62  virtual void accept(const std::shared_ptr<ionet::PacketSocket>& pAcceptedSocket, const ConnectCallback& callback) = 0;
63 
65  virtual void shutdown() = 0;
66  };
67 
70  std::shared_ptr<PacketWriters> CreatePacketWriters(
71  const std::shared_ptr<thread::IoThreadPool>& pPool,
72  const crypto::KeyPair& keyPair,
73  const ConnectionSettings& settings);
74 }}
ClientConnector.h
catapult::net::PacketWriters::connect
virtual void connect(const ionet::Node &node, const ConnectCallback &callback)=0
Attempts to connect to node and calls callback on completion.
catapult::utils::ModificationSafeIterableContainer::erase
void erase(iterator position)
Removes a single element at position from the container.
Definition: ModificationSafeIterableContainer.h:110
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
SpinLock.h
catapult::net::CreateClientConnector
std::shared_ptr< ClientConnector > CreateClientConnector(const std::shared_ptr< thread::IoThreadPool > &pPool, const crypto::KeyPair &keyPair, const ConnectionSettings &settings)
Creates a client connector for a server with a key pair of keyPair using pPool and configured with se...
Definition: ClientConnector.cpp:104
catapult::net::PacketWriters
Manages a collection of connections that send data to external nodes.
Definition: PacketWriters.h:41
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::net::ConnectionSettings
Settings used to configure connections.
Definition: ConnectionSettings.h:31
catapult::utils::ModificationSafeIterableContainer::size
size_t size() const
Gets the number of elements in the container.
Definition: ModificationSafeIterableContainer.h:35
m_pClientConnector
std::shared_ptr< ClientConnector > m_pClientConnector
Definition: PacketWriters.cpp:418
catapult::utils::ModificationSafeIterableContainer::nextIf
value_type * nextIf(TPredicate predicate)
Definition: ModificationSafeIterableContainer.h:82
colorPrint.warning
def warning(*args)
Definition: colorPrint.py:10
catapult::net::CreateServerConnector
std::shared_ptr< ServerConnector > CreateServerConnector(const std::shared_ptr< thread::IoThreadPool > &pPool, const crypto::KeyPair &keyPair, const ConnectionSettings &settings)
Creates a server connector for a server with a key pair of keyPair using pPool and configured with se...
Definition: ServerConnector.cpp:119
PacketWriters.h
m_errorCallback
ErrorCallback m_errorCallback
Definition: PacketWriters.cpp:250
catapult::net::PacketWriters::broadcast
virtual void broadcast(const ionet::PacketPayload &payload)=0
Broadcasts payload to all active connections.
m_pPacketIo
std::shared_ptr< ionet::PacketIo > m_pPacketIo
Definition: PacketWriters.cpp:247
ConnectionContainer.h
catapult::ionet::SocketOperationCode
SocketOperationCode
Enumeration of socket operation results.
Definition: SocketOperationCode.h:50
PacketWriters
net::PacketWriters & PacketWriters
Definition: PeersConnectionTasks.cpp:105
PacketIoPicker.h
pBufferedIo
std::shared_ptr< ionet::PacketIo > pBufferedIo
Definition: PacketWriters.cpp:47
PacketSocket.h
catapult::crypto::KeyPair
Represents a pair of private key with associated public key.
Definition: KeyPair.h:33
HexFormatter.h
m_nodeIdentityKeys
utils::KeySet m_nodeIdentityKeys
Definition: PacketWriters.cpp:197
m_pServerConnector
std::shared_ptr< ServerConnector > m_pServerConnector
Definition: PacketWriters.cpp:419
catapult::utils::ModificationSafeIterableContainer::iterator
typename TContainer::iterator iterator
Definition: ModificationSafeIterableContainer.h:31
catapult::net::PacketWriters::numActiveWriters
virtual size_t numActiveWriters() const =0
Gets the number of active writers.
IoThreadPool.h
ConnectionSettings.h
m_writers
Writers m_writers
Definition: PacketWriters.cpp:199
catapult::utils::KeySet
ArraySet< Key > KeySet
A key set.
Definition: ArraySet.h:64
size
uint64_t size
Definition: MemoryCounters.cpp:65
m_lock
utils::SpinLock m_lock
Definition: PacketWriters.cpp:200
catapult::net::PacketWriters::numAvailableWriters
virtual size_t numAvailableWriters() const =0
catapult::action
std::function< void()> action
An action function.
Definition: functions.h:27
catapult::net::PacketWriters::ConnectCallback
consumer< const PeerConnectResult & > ConnectCallback
Definition: PacketWriters.h:43
catapult::utils::ModificationSafeIterableContainer::cbegin
auto cbegin() const
Returns a const iterator that represents the first entity.
Definition: ModificationSafeIterableContainer.h:46
m_pPool
std::shared_ptr< thread::IoThreadPool > m_pPool
Definition: PacketWriters.cpp:417
catapult::net::ConnectionContainer
Manages a collection of connections.
Definition: ConnectionContainer.h:27
catapult::utils::ModificationSafeIterableContainer::end
auto end()
Returns an iterator that represents one past the last entity.
Definition: ModificationSafeIterableContainer.h:61
catapult::net::PacketIoPicker
An interface for picking packet io pairs.
Definition: PacketIoPicker.h:30
ThrottleLogger.h
m_completionCallback
CompletionCallback m_completionCallback
Definition: PacketWriters.cpp:251
CATAPULT_LOG_THROTTLE
#define CATAPULT_LOG_THROTTLE(LEVEL, THROTTLE_MILLIS)
Definition: ThrottleLogger.h:76
ServerConnector.h
catapult::net::CreatePacketWriters
std::shared_ptr< PacketWriters > CreatePacketWriters(const std::shared_ptr< thread::IoThreadPool > &pPool, const crypto::KeyPair &keyPair, const ConnectionSettings &settings)
Definition: PacketWriters.cpp:425
PeerConnectResult.h
m_outgoingNodeIdentityKeys
utils::KeySet m_outgoingNodeIdentityKeys
Definition: PacketWriters.cpp:198
m_networkIdentifier
model::NetworkIdentifier m_networkIdentifier
Definition: PacketWriters.cpp:420
catapult::utils::ModificationSafeIterableContainer::clear
void clear()
Removes all elements from the container.
Definition: ModificationSafeIterableContainer.h:122
pSocket
SocketPointer pSocket
Definition: PacketWriters.cpp:46
Node
ionet::Node Node
Definition: PacketWriters.cpp:45
catapult::ionet::PacketPayload
A packet payload that can be written.
Definition: PacketPayload.h:29
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::utils::ModificationSafeIterableContainer::cend
auto cend() const
Returns a const iterator that represents one past the last entity.
Definition: ModificationSafeIterableContainer.h:51
ModificationSafeIterableContainer.h
IsAvailable
bool IsAvailable
Definition: PacketWriters.cpp:44
catapult::net::PacketWriters::accept
virtual void accept(const std::shared_ptr< ionet::PacketSocket > &pAcceptedSocket, const ConnectCallback &callback)=0
Accepts a connection represented by pAcceptedSocket and calls callback on completion.
catapult::ionet::Node
A node in the catapult network.
Definition: Node.h:82
catapult::consumer
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
catapult::utils::ModificationSafeIterableContainer::push_back
void push_back(const value_type &value)
Adds a new element at the end of the container.
Definition: ModificationSafeIterableContainer.h:101
catapult::Key
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
catapult::utils::SpinLockGuard
std::lock_guard< SpinLock > SpinLockGuard
A spin lock guard.
Definition: SpinLock.h:60
catapult::net::PacketWriters::shutdown
virtual void shutdown()=0
Shuts down all connections.
TimedCallback.h
catapult::utils::ModificationSafeIterableContainer::begin
auto begin()
Returns an iterator that represents the first entity.
Definition: ModificationSafeIterableContainer.h:56