Class: DEVp2p::P2PProtocol
- Defined in:
- lib/devp2p/p2p_protocol.rb
Overview
DEV P2P Wire Protocol
Defined Under Namespace
Classes: Disconnect, Hello, Ping, Pong
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Attributes inherited from Protocol
Class Method Summary collapse
-
.get_hello_packet(data) ⇒ Object
special: we need this packet before the protocol can be initialized.
Instance Method Summary collapse
-
#initialize(peer, service) ⇒ P2PProtocol
constructor
A new instance of P2PProtocol.
- #stop ⇒ Object
Methods inherited from Protocol
#receive_packet, #send_packet, #start, #stopped?, #to_s
Methods included from Configurable
Constructor Details
#initialize(peer, service) ⇒ P2PProtocol
Returns a new instance of P2PProtocol.
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/devp2p/p2p_protocol.rb', line 138 def initialize(peer, service) raise ArgumentError, "invalid peer" unless peer.respond_to?(:capabilities) raise ArgumentError, "invalid peer" unless peer.respond_to?(:stop) raise ArgumentError, "invalid peer" unless peer.respond_to?(:receive_hello) @config = peer.config super(peer, service) @monitor = ConnectionMonitor.new self end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
136 137 138 |
# File 'lib/devp2p/p2p_protocol.rb', line 136 def config @config end |
Class Method Details
.get_hello_packet(data) ⇒ Object
special: we need this packet before the protocol can be initialized
125 126 127 128 |
# File 'lib/devp2p/p2p_protocol.rb', line 125 def get_hello_packet(data) payload = Hello.encode_payload(data.merge(version: 55)) Packet.new protocol_id, Hello.cmd_id, payload end |
Instance Method Details
#stop ⇒ Object
149 150 151 152 |
# File 'lib/devp2p/p2p_protocol.rb', line 149 def stop @monitor.stop super end |