Class: Zold::Fetch
- Inherits:
-
Object
- Object
- Zold::Fetch
- Includes:
- ThreadBadge
- Defined in:
- lib/zold/commands/fetch.rb
Overview
FETCH pulling command
Instance Method Summary collapse
-
#initialize(wallets:, remotes:, copies:, log: Log::NULL) ⇒ Fetch
constructor
A new instance of Fetch.
- #run(args = []) ⇒ Object
Constructor Details
Instance Method Details
#run(args = []) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/zold/commands/fetch.rb', line 58 def run(args = []) opts = Slop.parse(args, help: true, suppress_errors: true) do |o| o. = "Usage: zold fetch [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 fetch from it', default: [] o.bool '--quiet-if-absent', 'Don\'t fail if the wallet is absent in all remote nodes', default: false o.string '--network', 'The name of the network we work in', default: 'test' o.integer '--threads', "How many threads to use for fetching 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| fetch(id, Copies.new(File.join(@copies, id)), opts) @log.debug("Worker: #{Parallel.worker_number} has fetched wallet #{id}") end end |