Class: Zold::Routines::Spread

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/commands/routines/spread.rb

Overview

Spread them

Instance Method Summary collapse

Constructor Details

#initialize(opts, wallets, remotes, copies, log: Log::NULL) ⇒ Spread

Returns a new instance of Spread.



37
38
39
40
41
42
43
# File 'lib/zold/commands/routines/spread.rb', line 37

def initialize(opts, wallets, remotes, copies, log: Log::NULL)
  @opts = opts
  @wallets = wallets
  @remotes = remotes
  @copies = copies
  @log = log
end

Instance Method Details

#exec(_ = 0) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/zold/commands/routines/spread.rb', line 45

def exec(_ = 0)
  sleep(60) unless @opts['routine-immediately']
  @wallets.all.sample(100).each do |id|
    next if Copies.new(File.join(@copies, id)).all.count < 2
    Push.new(wallets: @wallets, remotes: @remotes, log: @log).run(
      ['push', "--network=#{@opts['network']}", id.to_s]
    )
  end
end