Class: DEVp2p::Discovery::Node
- Inherits:
-
Kademlia::Node
- Object
- Kademlia::Node
- DEVp2p::Discovery::Node
- Defined in:
- lib/devp2p/discovery/node.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
Attributes inherited from Kademlia::Node
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pubkey, address = nil) ⇒ Node
constructor
A new instance of Node.
- #to_uri ⇒ Object
Methods inherited from Kademlia::Node
#==, #distance, #id_distance, #to_s
Constructor Details
#initialize(pubkey, address = nil) ⇒ Node
Returns a new instance of Node.
15 16 17 18 19 20 21 22 23 |
# File 'lib/devp2p/discovery/node.rb', line 15 def initialize(pubkey, address=nil) raise ArgumentError, 'invalid address' unless address.nil? || address.is_a?(Address) super(pubkey) self.address = address @reputation = 0 @rlpx_version = 0 end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
13 14 15 |
# File 'lib/devp2p/discovery/node.rb', line 13 def address @address end |
Class Method Details
.from_uri(uri) ⇒ Object
8 9 10 11 |
# File 'lib/devp2p/discovery/node.rb', line 8 def self.from_uri(uri) ip, port, pubkey = Utils.host_port_pubkey_from_uri(uri) new(pubkey, Address.new(ip, port.to_i)) end |
Instance Method Details
#to_uri ⇒ Object
25 26 27 |
# File 'lib/devp2p/discovery/node.rb', line 25 def to_uri Utils.host_port_pubkey_to_uri(address.ip, address.udp_port, pubkey) end |