Class: Zold::Push

Inherits:
Object
  • Object
show all
Includes:
ThreadBadge
Defined in:
lib/zold/commands/push.rb

Overview

Wallet pushing command

Defined Under Namespace

Classes: EdgesOnly, NoQuorum

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, remotes:, log: Loog::NULL) ⇒ Push

Returns a new instance of Push.



38
39
40
41
42
# File 'lib/zold/commands/push.rb', line 38

def initialize(wallets:, remotes:, log: Loog::NULL)
  @wallets = wallets
  @remotes = remotes
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/zold/commands/push.rb', line 44

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold push [ID...] [options]
Available options:"
    o.bool '--ignore-score-weakness',
      'Don\'t complain when their score is too weak',
      default: false
    o.bool '--tolerate-edges',
      'Don\'t fail if only "edge" (not "master" ones) nodes accepted the wallet',
      default: false
    o.integer '--tolerate-quorum',
      'The minimum number of nodes required for a successful fetch (default: 4)',
      default: 4
    o.bool '--quiet-if-missed',
      'Don\'t fail if the wallet wasn\'t delivered to any remotes',
      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: 1)',
      default: 1
    o.integer '--retry',
      'How many times to retry each node before reporting a failure (default: 2)',
      default: 2
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  list = mine.empty? ? @wallets.all : mine.map { |i| Id.new(i) }
  Hands.exec(opts['threads'], list.uniq) do |id|
    push(id, opts)
  end
end