Fabcoin Core  0.16.2
P2P Digital Currency
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
dev::p2p::Session Class Reference

The Session class. More...

#include <Session.h>

Inheritance diagram for dev::p2p::Session:
[legend]
Collaboration diagram for dev::p2p::Session:
[legend]

Classes

struct  Framing
 

Public Member Functions

 Session (Host *_server, std::unique_ptr< RLPXFrameCoder > &&_io, std::shared_ptr< RLPXSocket > const &_s, std::shared_ptr< Peer > const &_n, PeerSessionInfo _info)
 
virtual ~Session ()
 
void start () override
 
void disconnect (DisconnectReason _reason) override
 
void ping () override
 
bool isConnected () const override
 
NodeID id () const override
 
void sealAndSend (RLPStream &_s, uint16_t _protocolID) override
 
int rating () const override
 
void addRating (int _r) override
 
void addNote (std::string const &_k, std::string const &_v) override
 
PeerSessionInfo info () const override
 
std::chrono::steady_clock::time_point connectionTime () override
 
void registerCapability (CapDesc const &_desc, std::shared_ptr< Capability > _p) override
 
void registerFraming (uint16_t _id) override
 
std::map< CapDesc, std::shared_ptr< Capability > > const & capabilities () const override
 
std::shared_ptr< Peerpeer () const override
 
std::chrono::steady_clock::time_point lastReceived () const override
 
ReputationManagerrepMan () override
 
- Public Member Functions inherited from dev::p2p::SessionFace
virtual ~SessionFace ()
 

Static Public Member Functions

static bool isFramingAllowedForVersion (unsigned _version)
 

Private Member Functions

void send (bytes &&_msg, uint16_t _protocolID)
 
void drop (DisconnectReason _r)
 Drop the connection for the reason _r. More...
 
void doRead ()
 Perform a read on the socket. More...
 
void doReadFrames ()
 
bool checkRead (std::size_t _expected, boost::system::error_code _ec, std::size_t _length)
 Check error code after reading and drop peer if error code. More...
 
void write ()
 Perform a single round of the write operation. This could end up calling itself asynchronously. More...
 
void writeFrames ()
 
bool readPacket (uint16_t _capId, PacketType _t, RLP const &_r)
 Deliver RLPX packet to Session or Capability for interpretation. More...
 
bool interpret (PacketType _t, RLP const &_r)
 Interpret an incoming Session packet. More...
 
bool isFramingEnabled () const
 
unsigned maxFrameSize () const
 
std::shared_ptr< FraminggetFraming (uint16_t _protocolID)
 
void multiplexAll ()
 

Static Private Member Functions

static RLPStreamprep (RLPStream &_s, PacketType _t, unsigned _args=0)
 
static bool checkPacket (bytesConstRef _msg)
 

Private Attributes

Hostm_server
 The host that owns us. Never null. More...
 
std::unique_ptr< RLPXFrameCoderm_io
 Transport over which packets are sent. More...
 
std::shared_ptr< RLPXSocketm_socket
 Socket of peer's connection. More...
 
Mutex x_framing
 Mutex for the write queue. More...
 
std::deque< bytesm_writeQueue
 The write queue. More...
 
std::vector< bytem_data
 Buffer for ingress packet data. More...
 
bytes m_incoming
 Read buffer for ingress bytes. More...
 
std::shared_ptr< Peerm_peer
 The Peer object. More...
 
bool m_dropped = false
 If true, we've already divested ourselves of this peer. We're just waiting for the reads & writes to fail before the shared_ptr goes OOS and the destructor kicks in. More...
 
Mutex x_info
 
PeerSessionInfo m_info
 Dynamic information about this peer. More...
 
std::chrono::steady_clock::time_point m_connect
 Time point of connection. More...
 
std::chrono::steady_clock::time_point m_ping
 Time point of last ping. More...
 
std::chrono::steady_clock::time_point m_lastReceived
 Time point of last message. More...
 
std::map< CapDesc, std::shared_ptr< Capability > > m_capabilities
 The peer's capability set. More...
 
std::map< uint16_t, std::shared_ptr< Framing > > m_framing
 
std::deque< bytesm_encFrames
 

Detailed Description

The Session class.

Todo:
Document fully.

Definition at line 90 of file Session.h.

Constructor & Destructor Documentation

Session::Session ( Host _server,
std::unique_ptr< RLPXFrameCoder > &&  _io,
std::shared_ptr< RLPXSocket > const &  _s,
std::shared_ptr< Peer > const &  _n,
PeerSessionInfo  _info 
)

Definition at line 35 of file Session.cpp.

Here is the call graph for this function:

Session::~Session ( )
virtual

Definition at line 50 of file Session.cpp.

Here is the call graph for this function:

Member Function Documentation

void dev::p2p::Session::addNote ( std::string const &  _k,
std::string const &  _v 
)
inlineoverridevirtual

Implements dev::p2p::SessionFace.

Definition at line 112 of file Session.h.

void Session::addRating ( int  _r)
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 84 of file Session.cpp.

std::map<CapDesc, std::shared_ptr<Capability> > const& dev::p2p::Session::capabilities ( ) const
inlineoverridevirtual

Implements dev::p2p::SessionFace.

Definition at line 120 of file Session.h.

bool Session::checkPacket ( bytesConstRef  _msg)
staticprivate
Returns
true iff the _msg forms a valid message for sending or receiving on the network.

Definition at line 209 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Session::checkRead ( std::size_t  _expected,
boost::system::error_code  _ec,
std::size_t  _length 
)
private

Check error code after reading and drop peer if error code.

Definition at line 452 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::chrono::steady_clock::time_point dev::p2p::Session::connectionTime ( )
inlineoverridevirtual

Implements dev::p2p::SessionFace.

Definition at line 115 of file Session.h.

Here is the call graph for this function:

void Session::disconnect ( DisconnectReason  _reason)
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 351 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::doRead ( )
private

Perform a read on the socket.

read padded frame and mac

Definition at line 374 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::doReadFrames ( )
private

Definition at line 479 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::drop ( DisconnectReason  _r)
private

Drop the connection for the reason _r.

Definition at line 327 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::shared_ptr< Session::Framing > Session::getFraming ( uint16_t  _protocolID)
private

Definition at line 557 of file Session.cpp.

Here is the caller graph for this function:

NodeID Session::id ( ) const
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 79 of file Session.cpp.

PeerSessionInfo dev::p2p::Session::info ( ) const
inlineoverridevirtual

Implements dev::p2p::SessionFace.

Definition at line 114 of file Session.h.

Here is the caller graph for this function:

bool Session::interpret ( PacketType  _t,
RLP const &  _r 
)
private

Interpret an incoming Session packet.

Definition at line 149 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool dev::p2p::Session::isConnected ( ) const
inlineoverridevirtual

Implements dev::p2p::SessionFace.

Definition at line 103 of file Session.h.

Here is the call graph for this function:

static bool dev::p2p::Session::isFramingAllowedForVersion ( unsigned  _version)
inlinestatic

Definition at line 93 of file Session.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool dev::p2p::Session::isFramingEnabled ( ) const
inlineprivate

Definition at line 189 of file Session.h.

Here is the caller graph for this function:

std::chrono::steady_clock::time_point dev::p2p::Session::lastReceived ( ) const
inlineoverridevirtual

Implements dev::p2p::SessionFace.

Definition at line 124 of file Session.h.

Here is the call graph for this function:

unsigned dev::p2p::Session::maxFrameSize ( ) const
inlineprivate

Definition at line 190 of file Session.h.

Here is the caller graph for this function:

void Session::multiplexAll ( )
private

Definition at line 585 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::shared_ptr<Peer> dev::p2p::Session::peer ( ) const
inlineoverridevirtual

Implements dev::p2p::SessionFace.

Definition at line 122 of file Session.h.

void Session::ping ( )
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 190 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

RLPStream & Session::prep ( RLPStream _s,
PacketType  _t,
unsigned  _args = 0 
)
staticprivate

Definition at line 197 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int Session::rating ( ) const
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 95 of file Session.cpp.

bool Session::readPacket ( uint16_t  _capId,
PacketType  _t,
RLP const &  _r 
)
private

Deliver RLPX packet to Session or Capability for interpretation.

Definition at line 114 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::registerCapability ( CapDesc const &  _desc,
std::shared_ptr< Capability _p 
)
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 565 of file Session.cpp.

void Session::registerFraming ( uint16_t  _id)
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 573 of file Session.cpp.

Here is the caller graph for this function:

ReputationManager & Session::repMan ( )
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 74 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::sealAndSend ( RLPStream _s,
uint16_t  _protocolID 
)
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 202 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::send ( bytes &&  _msg,
uint16_t  _protocolID 
)
private

Definition at line 218 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::start ( )
overridevirtual

Implements dev::p2p::SessionFace.

Definition at line 364 of file Session.cpp.

Here is the call graph for this function:

void Session::write ( )
private

Perform a single round of the write operation. This could end up calling itself asynchronously.

Definition at line 258 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Session::writeFrames ( )
private

Definition at line 289 of file Session.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::map<CapDesc, std::shared_ptr<Capability> > dev::p2p::Session::m_capabilities
private

The peer's capability set.

Definition at line 175 of file Session.h.

std::chrono::steady_clock::time_point dev::p2p::Session::m_connect
private

Time point of connection.

Definition at line 171 of file Session.h.

std::vector<byte> dev::p2p::Session::m_data
private

Buffer for ingress packet data.

Definition at line 162 of file Session.h.

bool dev::p2p::Session::m_dropped = false
private

If true, we've already divested ourselves of this peer. We're just waiting for the reads & writes to fail before the shared_ptr goes OOS and the destructor kicks in.

Definition at line 166 of file Session.h.

std::deque<bytes> dev::p2p::Session::m_encFrames
private

Definition at line 187 of file Session.h.

std::map<uint16_t, std::shared_ptr<Framing> > dev::p2p::Session::m_framing
private

Definition at line 186 of file Session.h.

bytes dev::p2p::Session::m_incoming
private

Read buffer for ingress bytes.

Definition at line 163 of file Session.h.

PeerSessionInfo dev::p2p::Session::m_info
private

Dynamic information about this peer.

Definition at line 169 of file Session.h.

std::unique_ptr<RLPXFrameCoder> dev::p2p::Session::m_io
private

Transport over which packets are sent.

Definition at line 158 of file Session.h.

std::chrono::steady_clock::time_point dev::p2p::Session::m_lastReceived
private

Time point of last message.

Definition at line 173 of file Session.h.

std::shared_ptr<Peer> dev::p2p::Session::m_peer
private

The Peer object.

Definition at line 165 of file Session.h.

std::chrono::steady_clock::time_point dev::p2p::Session::m_ping
private

Time point of last ping.

Definition at line 172 of file Session.h.

Host* dev::p2p::Session::m_server
private

The host that owns us. Never null.

Definition at line 156 of file Session.h.

std::shared_ptr<RLPXSocket> dev::p2p::Session::m_socket
private

Socket of peer's connection.

Definition at line 159 of file Session.h.

std::deque<bytes> dev::p2p::Session::m_writeQueue
private

The write queue.

Definition at line 161 of file Session.h.

Mutex dev::p2p::Session::x_framing
private

Mutex for the write queue.

Definition at line 160 of file Session.h.

Mutex dev::p2p::Session::x_info
mutableprivate

Definition at line 168 of file Session.h.


The documentation for this class was generated from the following files: