class DEVp2p::Kademlia::Node
Attributes
address[RW]
id[RW]
Public Class Methods
new(pubkey)
click to toggle source
# File lib/devp2p/kademlia/node.rb, line 10 def initialize(pubkey) raise ArgumentError, "invalid pubkey" unless pubkey.size == 64 @id = Crypto.keccak256(pubkey) raise "invalid node id" unless @id.size * 8 == ID_SIZE @id = Utils.big_endian_to_int @id @pubkey = pubkey end
Public Instance Methods
==(other)
click to toggle source
# File lib/devp2p/kademlia/node.rb, line 28 def ==(other) other.instance_of?(self.class) && pubkey == other.pubkey end
distance(other)
click to toggle source
# File lib/devp2p/kademlia/node.rb, line 20 def distance(other) id ^ other.id end
id_distance(_id)
click to toggle source
# File lib/devp2p/kademlia/node.rb, line 24 def id_distance(_id) id ^ _id end
to_s()
click to toggle source
# File lib/devp2p/kademlia/node.rb, line 32 def to_s "<Node(#{Utils.encode_hex pubkey[0,8]})>" end
Also aliased as: inspect