class DEVp2p::P2PProtocol::Hello

Public Instance Methods

create(proto) click to toggle source
# File lib/devp2p/p2p_protocol.rb, line 37
def create(proto)
  { version: proto.class.version,
    client_version_string: proto.config[:client_version_string],
    capabilities: proto.peer.capabilities,
    listen_port: proto.config[:p2p][:listen_port],
    remote_pubkey: proto.config[:node][:id] }
end
receive(proto, data) click to toggle source
Calls superclass method DEVp2p::Command#receive
# File lib/devp2p/p2p_protocol.rb, line 45
def receive(proto, data)
  logger.debug 'receive_hello', peer: proto.peer, version: data[:version]

  reasons = proto.class::Disconnect::Reason
  if data[:remote_pubkey] == proto.config[:node][:id]
    logger.debug 'connected myself'
    return proto.send_disconnect(reason: reasons[:connected_to_self])
  end

  proto.peer.async.receive_hello proto, data
  super(proto, data)
end

Private Instance Methods

logger() click to toggle source
# File lib/devp2p/p2p_protocol.rb, line 60
def logger
  @logger = Logger.new "p2p.protocol"
end