48 class ReputationManager;
55 virtual void start() = 0;
58 virtual void ping() = 0;
66 virtual int rating()
const = 0;
69 virtual void addNote(std::string
const& _k, std::string
const& _v) = 0;
77 virtual std::map<CapDesc, std::shared_ptr<Capability>>
const&
capabilities()
const = 0;
79 virtual std::shared_ptr<Peer>
peer()
const = 0;
95 Session(
Host* _server, std::unique_ptr<RLPXFrameCoder>&& _io, std::shared_ptr<RLPXSocket>
const& _s, std::shared_ptr<Peer>
const& _n,
PeerSessionInfo _info);
98 void start()
override;
101 void ping()
override;
103 bool isConnected()
const override {
return m_socket->ref().is_open(); }
109 int rating()
const override;
112 void addNote(std::string
const& _k, std::string
const& _v)
override {
Guard l(x_info); m_info.notes[_k] = _v; }
120 std::map<CapDesc, std::shared_ptr<Capability>>
const&
capabilities()
const override {
return m_capabilities; }
122 std::shared_ptr<Peer>
peer()
const override {
return m_peer; }
131 void send(
bytes&& _msg, uint16_t _protocolID);
141 bool checkRead(std::size_t _expected, boost::system::error_code _ec, std::size_t _length);
148 bool readPacket(uint16_t _capId,
PacketType _t,
RLP const& _r);
158 std::unique_ptr<RLPXFrameCoder>
m_io;
166 bool m_dropped =
false;
181 Framing(uint16_t _protocolID): writer(_protocolID), reader(_protocolID) {}
186 std::map<uint16_t, std::shared_ptr<Framing> >
m_framing;
191 std::shared_ptr<Framing> getFraming(uint16_t _protocolID);
195 template <
class PeerCap>
std::unique_ptr< RLPXFrameCoder > m_io
Transport over which packets are sent.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
unsigned maxFrameSize() const
bool isFramingEnabled() const
std::map< uint16_t, std::shared_ptr< Framing > > m_framing
virtual bool isConnected() const =0
bool isConnected() const override
virtual std::chrono::steady_clock::time_point lastReceived() const =0
std::chrono::steady_clock::time_point connectionTime() override
Mutex x_framing
Mutex for the write queue.
std::pair< std::string, u256 > CapDesc
virtual void registerCapability(CapDesc const &_desc, std::shared_ptr< Capability > _p)=0
static bool isFramingAllowedForVersion(unsigned _version)
unsigned const protocolVersion
The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not t...
std::shared_ptr< RLPXSocket > m_socket
Socket of peer's connection.
Framing(uint16_t _protocolID)
std::chrono::steady_clock::time_point m_lastReceived
Time point of last message.
std::deque< bytes > m_encFrames
virtual std::chrono::steady_clock::time_point connectionTime()=0
virtual void registerFraming(uint16_t _id)=0
std::lock_guard< std::mutex > Guard
virtual void sealAndSend(RLPStream &_s, uint16_t _protocolID)=0
bytes m_incoming
Read buffer for ingress bytes.
virtual int rating() const =0
std::vector< byte > bytes
std::shared_ptr< PeerCap > capabilityFromSession(SessionFace const &_session, u256 const &_version=PeerCap::version())
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
std::chrono::steady_clock::time_point lastReceived() const override
virtual std::map< CapDesc, std::shared_ptr< Capability > > const & capabilities() const =0
PeerSessionInfo info() const override
std::deque< bytes > m_writeQueue
The write queue.
std::map< CapDesc, std::shared_ptr< Capability > > m_capabilities
The peer's capability set.
std::shared_ptr< Peer > peer() const override
void addNote(std::string const &_k, std::string const &_v) override
std::vector< byte > m_data
Buffer for ingress packet data.
std::chrono::steady_clock::time_point m_ping
Time point of last ping.
clock::time_point time_point
virtual void addNote(std::string const &_k, std::string const &_v)=0
virtual std::shared_ptr< Peer > peer() const =0
std::chrono::steady_clock::time_point m_connect
Time point of connection.
virtual ReputationManager & repMan()=0
PeerSessionInfo m_info
Dynamic information about this peer.
RLPFrameReader Reads and assembles RLPX frame byte buffers into RLPX packets.
virtual void disconnect(DisconnectReason _reason)=0
Host * m_server
The host that owns us. Never null.
virtual PeerSessionInfo info() const =0
virtual void addRating(int _r)=0
Class for writing to an RLP bytestream.
std::shared_ptr< Peer > m_peer
The Peer object.
Class for interpreting Recursive Linear-Prefix Data.
std::map< CapDesc, std::shared_ptr< Capability > > const & capabilities() const override
virtual NodeID id() const =0
Multiplex packets into encrypted RLPX frames.