Class: Ciri::P2P::Kad::Node
- Inherits:
-
Object
- Object
- Ciri::P2P::Kad::Node
- Defined in:
- lib/ciri/p2p/kad.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#raw_node_id ⇒ Object
readonly
Returns the value of attribute raw_node_id.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #distance_to(id) ⇒ Object
-
#initialize(raw_node_id) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(raw_node_id) ⇒ Node
Returns a new instance of Node.
48 49 50 51 |
# File 'lib/ciri/p2p/kad.rb', line 48 def initialize(raw_node_id) @raw_node_id = raw_node_id @id = Utils.big_endian_decode(Utils.keccak(raw_node_id)) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
46 47 48 |
# File 'lib/ciri/p2p/kad.rb', line 46 def id @id end |
#raw_node_id ⇒ Object (readonly)
Returns the value of attribute raw_node_id.
46 47 48 |
# File 'lib/ciri/p2p/kad.rb', line 46 def raw_node_id @raw_node_id end |
Instance Method Details
#<=>(other) ⇒ Object
61 62 63 |
# File 'lib/ciri/p2p/kad.rb', line 61 def <=>(other) @id <=> other.id end |
#==(other) ⇒ Object
57 58 59 |
# File 'lib/ciri/p2p/kad.rb', line 57 def ==(other) self.class == other.class && self.id == other.id end |
#distance_to(id) ⇒ Object
53 54 55 |
# File 'lib/ciri/p2p/kad.rb', line 53 def distance_to(id) @id ^ id end |