Class: Zold::Routines::Spread

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

Overview

Spread random wallets to the network.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2018 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Spread.



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

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



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

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