Class: Zold::Push
- Inherits:
-
Object
- Object
- Zold::Push
- Includes:
- ThreadBadge
- Defined in:
- lib/zold/commands/push.rb
Overview
Wallet pushing command
Instance Method Summary collapse
-
#initialize(wallets:, remotes:, log: Log::NULL) ⇒ Push
constructor
A new instance of Push.
- #run(args = []) ⇒ Object
Constructor Details
Instance Method Details
#run(args = []) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/zold/commands/push.rb', line 53 def run(args = []) opts = Slop.parse(args, help: true, suppress_errors: true) do |o| o. = "Usage: zold push [ID...] [options] Available options:" o.bool '--ignore-score-weakness', 'Don\'t complain when their score is too weak', default: false o.array '--ignore-node', 'Ignore this node and don\'t push to it', default: [] o.integer '--threads', "How many threads to use for pushing wallets (default: #{[Concurrent.processor_count / 2, 2].max})", default: [Concurrent.processor_count / 2, 2].max o.bool '--help', 'Print instructions' end mine = Args.new(opts, @log).take || return Parallel.map((mine.empty? ? @wallets.all : mine.map { |i| Id.new(i) }), in_threads: opts[:threads]) do |id| push(id, opts) @log.debug("Worker: #{Parallel.worker_number} has pushed wallet #{id}") end end |