Class: Ciri::DevP2P::Protocol

Inherits:
Object
  • Object
show all
Defined in:
lib/ciri/devp2p/protocol.rb

Overview

protocol represent DevP2P sub protocols

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, version:, length:) ⇒ Protocol



28
29
30
31
32
33
# File 'lib/ciri/devp2p/protocol.rb', line 28

def initialize(name:, version:, length:)
  @name = name
  @version = version
  @length = length
  @start = nil
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



25
26
27
# File 'lib/ciri/devp2p/protocol.rb', line 25

def length
  @length
end

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/ciri/devp2p/protocol.rb', line 25

def name
  @name
end

#node_infoObject

Returns the value of attribute node_info.



26
27
28
# File 'lib/ciri/devp2p/protocol.rb', line 26

def node_info
  @node_info
end

#peer_infoObject

Returns the value of attribute peer_info.



26
27
28
# File 'lib/ciri/devp2p/protocol.rb', line 26

def peer_info
  @peer_info
end

#versionObject (readonly)

Returns the value of attribute version.



25
26
27
# File 'lib/ciri/devp2p/protocol.rb', line 25

def version
  @version
end

Instance Method Details

#start(peer, io) ⇒ Object

Raises:

  • (NotImplementedError)


39
40
41
42
# File 'lib/ciri/devp2p/protocol.rb', line 39

def start(peer, io)
  raise NotImplementedError.new('not set protocol start proc') unless @start
  @start.call(peer, io)
end

#start=(start_proc) ⇒ Object



35
36
37
# File 'lib/ciri/devp2p/protocol.rb', line 35

def start=(start_proc)
  @start = start_proc
end