CatapultServer
v0.5.0.1 (Elephant)
|
Namespaces | |
detail | |
operation_state | |
Classes | |
class | AcceptedPacketSocketInfo |
Result of a packet socket accept operation. More... | |
class | AppendContext |
class | BatchPacketReader |
An read-optimized interface for reading packets. More... | |
struct | ConnectionState |
Connection state unique to a node and connection identifier. More... | |
struct | NetworkNode |
Information about a catapult node that is propagated through the network. More... | |
class | Node |
A node in the catapult network. More... | |
class | NodeContainer |
A collection of nodes. More... | |
struct | NodeContainerData |
class | NodeContainerModifier |
A write only view on top of node container. More... | |
class | NodeContainerView |
A read only view on top of node container. More... | |
struct | NodeData |
struct | NodeEndpoint |
A node's publicly accessible endpoint. More... | |
struct | NodeHasher |
Hasher object for a node. More... | |
struct | NodeInfo |
Information about a node and its interactions. More... | |
struct | NodeInteractionResult |
Result from a node interaction. More... | |
struct | NodeInteractions |
Node interactions. More... | |
class | NodeInteractionsContainer |
Node interactions container. More... | |
struct | NodeMetadata |
Additional node information. More... | |
class | NodePacketIoPair |
A node and packet io pair. More... | |
struct | NodeVersion_tag |
struct | PackedConnectionState |
Connection state unique to a node and connection identifier. More... | |
struct | PackedNodeInfo |
Information about a node and its interactions. More... | |
struct | PackedNodeInteractions |
Node interactions. More... | |
struct | Packet |
A packet header with a data payload. More... | |
class | PacketExtractor |
Helper for extracting a packet from a working buffer. More... | |
struct | PacketHeader |
A packet header that all transferable information is expected to have. More... | |
class | PacketIo |
An interface for reading and writing packets. More... | |
class | PacketPayload |
A packet payload that can be written. More... | |
class | PacketPayloadBuilder |
A packet payload builder for creating payloads composed of heterogeneous data. More... | |
class | PacketPayloadFactory |
A factory for creating common packet payloads. More... | |
class | PacketReader |
class | PacketSocket |
struct | PacketSocketOptions |
Packet socket options. More... | |
struct | ReaderIdentity |
Identifying information about a reader. More... | |
struct | ServerPacketHandlerContext |
Context passed to a server packet handler function. More... | |
class | ServerPacketHandlers |
A collection of packet handlers where there is at most one handler per packet type. More... | |
struct | ServiceIdentifier_tag |
class | SocketReader |
Reads and consumes packets from a socket. More... | |
class | WorkingBuffer |
A buffer for storing working data. More... | |
Typedefs | |
using | ByteBuffer = std::vector< uint8_t > |
using | socket = boost::asio::ip::tcp::socket |
using | NodeVersion = utils::BaseValue< uint32_t, NodeVersion_tag > |
32-bit node version where first three bytes represent { major, minor, build } and last byte is user defined. More... | |
using | NodeSet = std::unordered_set< Node, NodeHasher > |
A set of nodes. More... | |
using | ServiceIdentifier = utils::BaseValue< uint32_t, ServiceIdentifier_tag > |
using | ConfigureSocketCallback = consumer< socket & > |
Callback for configuring a socket before initiating an accept. More... | |
using | AcceptCallback = consumer< const AcceptedPacketSocketInfo & > |
Callback for an accepted socket. More... | |
using | ConnectCallback = consumer< ConnectResult, const std::shared_ptr< PacketSocket > & > |
Callback for a connected socket. More... | |
Enumerations | |
enum | ConnectionSecurityMode : uint8_t { ConnectionSecurityMode::CONNECTION_SECURITY_MODE_LIST } |
Possible connection security modes. More... | |
enum | ConnectResult { ConnectResult::CONNECT_RESULT_LIST } |
Enumeration of possible connection results. More... | |
enum | NodeSource : uint32_t { NodeSource::NODE_SOURCE_LIST } |
enum | NodeInteractionResultCode { NodeInteractionResultCode::NODE_INTERACTION_RESULT_CODE_LIST } |
Possible node interaction result codes. More... | |
enum | NodeRoles : uint32_t { NodeRoles::None, NodeRoles::Peer = 0x01, NodeRoles::Api = 0x02 } |
A node's role. More... | |
enum | PacketExtractResult { PacketExtractResult::PACKET_EXTRACT_RESULT_LIST } |
Possible results from PacketExtractor::tryExtractNextPacket. More... | |
enum | PacketType : uint32_t { PacketType::PACKET_TYPE_LIST } |
An enumeration of known packet types. More... | |
enum | SocketOperationCode { SocketOperationCode::SOCKET_OPERATION_CODE_LIST } |
Enumeration of socket operation results. More... | |
Functions | |
PacketPayload | CreateBroadcastPayload (const std::shared_ptr< const model::Block > &pBlock) |
Creates a payload around pBlock for broadcasting. More... | |
PacketPayload | CreateBroadcastPayload (const std::vector< model::TransactionInfo > &transactionInfos) |
Creates a payload around transactionInfos for broadcasting. More... | |
PacketPayload | CreateBroadcastPayload (const std::vector< model::TransactionInfo > &transactionInfos, PacketType packetType) |
Creates a payload around transactionInfos for broadcasting using packetType. More... | |
PacketPayload | CreateBroadcastPayload (const std::vector< model::DetachedCosignature > &cosignatures) |
Creates a payload around cosignatures for broadcasting. More... | |
std::shared_ptr< PacketIo > | CreateBufferedPacketIo (const std::shared_ptr< PacketIo > &pIo, boost::asio::io_context::strand &strand) |
Adds buffering to pIo using strand for synchronization. More... | |
std::ostream & | operator<< (std::ostream &out, ConnectionSecurityMode value) |
Insertion operator for outputting value to out. More... | |
bool | TryParseValue (const std::string &str, ConnectionSecurityMode &modes) |
Tries to parse str into connection security modes. More... | |
std::ostream & | operator<< (std::ostream &out, ConnectResult value) |
Insertion operator for outputting value to out. More... | |
std::unique_ptr< NetworkNode > | PackNode (const Node &node) |
Packs a node model into a network node. More... | |
Node | UnpackNode (const NetworkNode &networkNode) |
Unpacks a network node (networkNode) into a node model. More... | |
std::ostream & | operator<< (std::ostream &out, const Node &node) |
NodeSet | FindAllActiveNodes (const NodeContainerView &view) |
Finds all active nodes in view. More... | |
std::ostream & | operator<< (std::ostream &out, NodeSource value) |
Insertion operator for outputting value to out. More... | |
std::ostream & | operator<< (std::ostream &out, NodeInteractionResultCode value) |
Insertion operator for outputting value to out. More... | |
bool | TryParseValue (const std::string &str, NodeRoles &roles) |
Tries to parse str into node roles. More... | |
template<typename TPacket > | |
std::shared_ptr< TPacket > | CreateSharedPacket (uint32_t payloadSize=0) |
Creates a packet of the specified type (TPacket) with the specified payload size. More... | |
template<> | |
std::shared_ptr< Packet > | CreateSharedPacket (uint32_t payloadSize) |
template<typename TPacket > | |
const TPacket * | CoercePacket (const Packet *pPacket) |
Coerces pPacket to the desired packet type or nullptr if it is incompatible. More... | |
constexpr bool | IsPacketValid (const Packet &packet, PacketType type) |
Checks if packet is valid with type. More... | |
size_t | CalculatePacketDataSize (const Packet &packet) |
Calculates the data size of packet. More... | |
template<typename TEntity > | |
bool | IsSizeValid (const TEntity &entity) |
Checks the real size of entity against its reported size and returns true if the sizes match. More... | |
template<typename TEntity , typename TIsValidPredicate > | |
model::EntityRange< TEntity > | ExtractEntitiesFromPacket (const Packet &packet, TIsValidPredicate isValid) |
template<typename TEntity , typename TIsValidPredicate > | |
std::unique_ptr< TEntity > | ExtractEntityFromPacket (const Packet &packet, TIsValidPredicate isValid) |
template<typename TStructure > | |
model::EntityRange< TStructure > | ExtractFixedSizeStructuresFromPacket (const Packet &packet) |
std::ostream & | operator<< (std::ostream &out, PacketExtractResult value) |
Insertion operator for outputting value to out. More... | |
std::ostream & | operator<< (std::ostream &out, const PacketHeader &header) |
Insertion operator for outputting header to out. More... | |
constexpr bool | IsPacketDataSizeValid (const PacketHeader &header, size_t maxPacketDataSize) |
Determines if header indicates a valid packet data size no greater than maxPacketDataSize. More... | |
template<typename TEntity , typename TIsValidPredicate > | |
std::vector< size_t > | ExtractEntityOffsets (const RawBuffer &buffer, TIsValidPredicate isValid) |
template<typename TEntity , typename TIsValidPredicate > | |
bool | ContainsSingleEntity (const RawBuffer &buffer, TIsValidPredicate isValid) |
template<typename TStructure > | |
size_t | CountFixedSizeStructures (const RawBuffer &buffer) |
void | Accept (boost::asio::ip::tcp::acceptor &acceptor, const PacketSocketOptions &options, const ConfigureSocketCallback &configureSocket, const AcceptCallback &accept) |
void | Accept (boost::asio::ip::tcp::acceptor &acceptor, const PacketSocketOptions &options, const AcceptCallback &accept) |
Accepts a connection using acceptor and calls accept on completion configuring the socket with options. More... | |
action | Connect (boost::asio::io_context &ioContext, const PacketSocketOptions &options, const NodeEndpoint &endpoint, const ConnectCallback &callback) |
std::ostream & | operator<< (std::ostream &out, PacketType value) |
Insertion operator for outputting value to out. More... | |
std::ostream & | operator<< (std::ostream &out, const ReaderIdentity &identity) |
Insertion operator for outputting identity to out. More... | |
std::shared_ptr< PacketSocket > | Secure (const std::shared_ptr< PacketSocket > &pSocket, ConnectionSecurityMode securityMode, const crypto::KeyPair &sourceKeyPair, const Key &remoteKey, utils::FileSize maxPacketDataSize) |
std::shared_ptr< PacketIo > | CreateSecureSignedPacketIo (const std::shared_ptr< PacketIo > &pIo, const crypto::KeyPair &sourceKeyPair, const Key &remoteKey, uint32_t maxSignedPacketDataSize) |
std::shared_ptr< BatchPacketReader > | CreateSecureSignedBatchPacketReader (const std::shared_ptr< BatchPacketReader > &pReader, const Key &remoteKey) |
std::ostream & | operator<< (std::ostream &out, SocketOperationCode value) |
Insertion operator for outputting value to out. More... | |
std::unique_ptr< SocketReader > | CreateSocketReader (const std::shared_ptr< BatchPacketReader > &pReader, const std::shared_ptr< PacketIo > &pWriter, const ServerPacketHandlers &handlers, const ReaderIdentity &identity) |
Creates a socket packet reader around pReader, pWriter and handlers given a reader identity. More... | |
using catapult::ionet::AcceptCallback = typedef consumer<const AcceptedPacketSocketInfo&> |
Callback for an accepted socket.
using catapult::ionet::ByteBuffer = typedef std::vector<uint8_t> |
using catapult::ionet::ConfigureSocketCallback = typedef consumer<socket&> |
Callback for configuring a socket before initiating an accept.
using catapult::ionet::ConnectCallback = typedef consumer<ConnectResult, const std::shared_ptr<PacketSocket>&> |
Callback for a connected socket.
using catapult::ionet::NodeSet = typedef std::unordered_set<Node, NodeHasher> |
A set of nodes.
using catapult::ionet::NodeVersion = typedef utils::BaseValue<uint32_t, NodeVersion_tag> |
32-bit node version where first three bytes represent { major, minor, build } and last byte is user defined.
using catapult::ionet::ServiceIdentifier = typedef utils::BaseValue<uint32_t, ServiceIdentifier_tag> |
using catapult::ionet::socket = typedef boost::asio::ip::tcp::socket |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
Possible results from PacketExtractor::tryExtractNextPacket.
Enumerator | |
---|---|
PACKET_EXTRACT_RESULT_LIST |
|
strong |
|
strong |
void catapult::ionet::Accept | ( | boost::asio::ip::tcp::acceptor & | acceptor, |
const PacketSocketOptions & | options, | ||
const AcceptCallback & | accept | ||
) |
Accepts a connection using acceptor and calls accept on completion configuring the socket with options.
void catapult::ionet::Accept | ( | boost::asio::ip::tcp::acceptor & | acceptor, |
const PacketSocketOptions & | options, | ||
const ConfigureSocketCallback & | configureSocket, | ||
const AcceptCallback & | accept | ||
) |
Accepts a connection using acceptor and calls accept on completion configuring the socket with options. configureSocket is called before starting the accept to allow custom configuration of asio sockets.
|
inline |
Calculates the data size of packet.
const TPacket* catapult::ionet::CoercePacket | ( | const Packet * | pPacket | ) |
Coerces pPacket to the desired packet type or nullptr
if it is incompatible.
action catapult::ionet::Connect | ( | boost::asio::io_context & | ioContext, |
const PacketSocketOptions & | options, | ||
const NodeEndpoint & | endpoint, | ||
const ConnectCallback & | callback | ||
) |
Attempts to connect a socket to the specified endpoint using ioContext and calls callback on completion configuring the socket with options. The returned function can be used to cancel the connect.
bool catapult::ionet::ContainsSingleEntity | ( | const RawBuffer & | buffer, |
TIsValidPredicate | isValid | ||
) |
Determines if buffer contains a single entity with a validity check (isValid).
false
will be returned. size_t catapult::ionet::CountFixedSizeStructures | ( | const RawBuffer & | buffer | ) |
Counts the number of fixed size structures in buffer.
0
will be returned. PacketPayload catapult::ionet::CreateBroadcastPayload | ( | const std::shared_ptr< const model::Block > & | pBlock | ) |
Creates a payload around pBlock for broadcasting.
PacketPayload catapult::ionet::CreateBroadcastPayload | ( | const std::vector< model::DetachedCosignature > & | cosignatures | ) |
Creates a payload around cosignatures for broadcasting.
PacketPayload catapult::ionet::CreateBroadcastPayload | ( | const std::vector< model::TransactionInfo > & | transactionInfos | ) |
Creates a payload around transactionInfos for broadcasting.
PacketPayload catapult::ionet::CreateBroadcastPayload | ( | const std::vector< model::TransactionInfo > & | transactionInfos, |
PacketType | packetType | ||
) |
Creates a payload around transactionInfos for broadcasting using packetType.
std::shared_ptr< PacketIo > catapult::ionet::CreateBufferedPacketIo | ( | const std::shared_ptr< PacketIo > & | pIo, |
boost::asio::io_context::strand & | strand | ||
) |
Adds buffering to pIo using strand for synchronization.
std::shared_ptr< BatchPacketReader > catapult::ionet::CreateSecureSignedBatchPacketReader | ( | const std::shared_ptr< BatchPacketReader > & | pReader, |
const Key & | remoteKey | ||
) |
Adds secure signing to all packets read from pReader.
std::shared_ptr< PacketIo > catapult::ionet::CreateSecureSignedPacketIo | ( | const std::shared_ptr< PacketIo > & | pIo, |
const crypto::KeyPair & | sourceKeyPair, | ||
const Key & | remoteKey, | ||
uint32_t | maxSignedPacketDataSize | ||
) |
Adds secure signing to all packets read from and written to pIo.
|
inline |
std::shared_ptr<TPacket> catapult::ionet::CreateSharedPacket | ( | uint32_t | payloadSize = 0 | ) |
Creates a packet of the specified type (TPacket) with the specified payload size.
std::unique_ptr< SocketReader > catapult::ionet::CreateSocketReader | ( | const std::shared_ptr< BatchPacketReader > & | pReader, |
const std::shared_ptr< PacketIo > & | pWriter, | ||
const ServerPacketHandlers & | handlers, | ||
const ReaderIdentity & | identity | ||
) |
Creates a socket packet reader around pReader, pWriter and handlers given a reader identity.
model::EntityRange<TEntity> catapult::ionet::ExtractEntitiesFromPacket | ( | const Packet & | packet, |
TIsValidPredicate | isValid | ||
) |
Extracts entities from packet with a validity check (isValid).
std::unique_ptr<TEntity> catapult::ionet::ExtractEntityFromPacket | ( | const Packet & | packet, |
TIsValidPredicate | isValid | ||
) |
Extracts a single entity from packet with a validity check (isValid).
nullptr
will be returned. std::vector<size_t> catapult::ionet::ExtractEntityOffsets | ( | const RawBuffer & | buffer, |
TIsValidPredicate | isValid | ||
) |
Extracts entity offsets from buffer with a validity check (isValid).
model::EntityRange<TStructure> catapult::ionet::ExtractFixedSizeStructuresFromPacket | ( | const Packet & | packet | ) |
Extracts fixed size structures from packet.
NodeSet catapult::ionet::FindAllActiveNodes | ( | const NodeContainerView & | view | ) |
Finds all active nodes in view.
|
constexpr |
Determines if header indicates a valid packet data size no greater than maxPacketDataSize.
|
constexpr |
Checks if packet is valid with type.
bool catapult::ionet::IsSizeValid | ( | const TEntity & | entity | ) |
Checks the real size of entity against its reported size and returns true
if the sizes match.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
ConnectionSecurityMode | value | ||
) |
Insertion operator for outputting value to out.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
ConnectResult | value | ||
) |
Insertion operator for outputting value to out.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
const Node & | node | ||
) |
std::ostream & catapult::ionet::operator<< | ( | std::ostream & | out, |
const PacketHeader & | header | ||
) |
Insertion operator for outputting header to out.
std::ostream & catapult::ionet::operator<< | ( | std::ostream & | out, |
const ReaderIdentity & | identity | ||
) |
Insertion operator for outputting identity to out.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
NodeInteractionResultCode | value | ||
) |
Insertion operator for outputting value to out.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
NodeSource | value | ||
) |
Insertion operator for outputting value to out.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
PacketExtractResult | value | ||
) |
Insertion operator for outputting value to out.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
PacketType | value | ||
) |
Insertion operator for outputting value to out.
std::ostream& catapult::ionet::operator<< | ( | std::ostream & | out, |
SocketOperationCode | value | ||
) |
Insertion operator for outputting value to out.
std::unique_ptr< NetworkNode > catapult::ionet::PackNode | ( | const Node & | node | ) |
Packs a node model into a network node.
std::shared_ptr< PacketSocket > catapult::ionet::Secure | ( | const std::shared_ptr< PacketSocket > & | pSocket, |
ConnectionSecurityMode | securityMode, | ||
const crypto::KeyPair & | sourceKeyPair, | ||
const Key & | remoteKey, | ||
utils::FileSize | maxPacketDataSize | ||
) |
Secures a packet socket (pSocket) to conform with securityMode for a connection from sourceKeyPair to remoteKey allowing a specified max packet data size (maxPacketDataSize).
bool catapult::ionet::TryParseValue | ( | const std::string & | str, |
ConnectionSecurityMode & | modes | ||
) |
Tries to parse str into connection security modes.
bool catapult::ionet::TryParseValue | ( | const std::string & | str, |
NodeRoles & | roles | ||
) |
Tries to parse str into node roles.
Node catapult::ionet::UnpackNode | ( | const NetworkNode & | networkNode | ) |
Unpacks a network node (networkNode) into a node model.