Class: Ciri::P2P::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ciri/p2p/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_node_id: nil, node_id: raw_node_id && NodeID.from_raw_id(raw_node_id), addresses:, added_at: nil) ⇒ Node

Returns a new instance of Node.



76
77
78
79
80
81
82
83
# File 'lib/ciri/p2p/node.rb', line 76

def initialize(raw_node_id: nil,
               node_id: raw_node_id && NodeID.from_raw_id(raw_node_id),
               addresses:,
               added_at: nil)
  @node_id = node_id
  @addresses = addresses
  @added_at = added_at
end

Instance Attribute Details

#added_atObject (readonly)

Returns the value of attribute added_at.



73
74
75
# File 'lib/ciri/p2p/node.rb', line 73

def added_at
  @added_at
end

#addressesObject

Returns the value of attribute addresses.



74
75
76
# File 'lib/ciri/p2p/node.rb', line 74

def addresses
  @addresses
end

#node_idObject (readonly)

Returns the value of attribute node_id.



73
74
75
# File 'lib/ciri/p2p/node.rb', line 73

def node_id
  @node_id
end

Instance Method Details

#==(other) ⇒ Object



85
86
87
# File 'lib/ciri/p2p/node.rb', line 85

def == (other)
  self.class == other.class && node_id == other.node_id
end

#raw_node_idObject



89
90
91
# File 'lib/ciri/p2p/node.rb', line 89

def raw_node_id
  node_id.to_bytes
end