Class: Ciri::DevP2P::Server::Dial

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

Overview

Discovery and dial new nodes

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Dial

Returns a new instance of Dial.


109
110
111
112
# File 'lib/ciri/devp2p/server.rb', line 109

def initialize(server)
  @server = server
  @cache = []
end

Instance Method Details

#find_peer_tasks(running_count, peers, now) ⇒ Object

return new tasks to find peers


115
116
117
118
119
120
121
122
# File 'lib/ciri/devp2p/server.rb', line 115

def find_peer_tasks(running_count, peers, now)
  node = @server.bootstrap_nodes[0]
  return [] if @cache.include?(node)
  @cache << node
  [Task.new(name: 'find peer') {
    @server.setup_connection(node)
  }]
end