Class: Ciri::P2P::DialScheduler

Inherits:
Object
  • Object
show all
Includes:
Utils::Logger
Defined in:
lib/ciri/p2p/dial_scheduler.rb

Overview

DialScheduler establish outoging connections

Instance Method Summary collapse

Constructor Details

#initialize(network_state, dialer, dial_outgoing_interval_secs: 15) ⇒ DialScheduler

Returns a new instance of DialScheduler.



36
37
38
39
40
# File 'lib/ciri/p2p/dial_scheduler.rb', line 36

def initialize(network_state, dialer, dial_outgoing_interval_secs: 15)
  @network_state = network_state
  @dialer = dialer
  @dial_outgoing_interval_secs = dial_outgoing_interval_secs
end

Instance Method Details

#run(task: Async::Task.current) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/ciri/p2p/dial_scheduler.rb', line 42

def run(task: Async::Task.current)
  dial_bootnodes
  # dial outgoing peers every 15 seconds
  task.reactor.every(@dial_outgoing_interval_secs) do
    task.async do
      schedule_dialing_tasks
    end
  end
end