zold 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f2635ac65d327c6ef19ec965976a6de7961fce5
4
- data.tar.gz: 9a5cb6ef5aab7e9217a0131eac7fa422a95fb559
3
+ metadata.gz: 73513e03f0456f1f174a5fbda8880d05ad26b4e6
4
+ data.tar.gz: 0c5fa14573661f65ddba4dbfa65afdc1e010c60d
5
5
  SHA512:
6
- metadata.gz: 3c6f1a464e2b81427cecb31ee26ed73ce8413635bc42156566b3927b214664ec3d862786880892102ecee5a94c10ce5e3c65d54d2ad85882d914dca603d0f58d
7
- data.tar.gz: 57d24db630188ab12d0d23b3ec6aae112f94f79895b5092653f17d41f3352528d895cbe7ec227e7d014259a328f1aeb18cf978afbc8b9eb66cd39df6d477ddbb
6
+ metadata.gz: 181d60dd63b4fdc24d88f5af921f76dcd8e0b39f9f8b49103dc36d10d7f7c0da4d44ac52ac19206b5811ebb77e6eddae88509be19c62cd781928532f68c981bc
7
+ data.tar.gz: 1e06c4d01f5dc12a52b6ebe9c475de20555ee376aa9395d991b57f17b8f466553dab66142b99b38128cf04d33cb27514deaadb25faf771af9604437dbc84b40c
@@ -44,6 +44,9 @@ module Zold
44
44
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
45
45
  o.banner = "Usage: zold push [ID...] [options]
46
46
  Available options:"
47
+ o.array '--ignore-node',
48
+ 'Ignore this node and don\'t push to it',
49
+ default: []
47
50
  o.bool '--sync',
48
51
  'Wait until the server confirms merge and pushes all wallets further (default: false)',
49
52
  default: false
@@ -63,23 +66,31 @@ Available options:"
63
66
  def push(wallet, opts)
64
67
  total = 0
65
68
  @remotes.iterate(@log) do |r|
66
- start = Time.now
67
- response = r.http(
68
- "/wallet/#{wallet.id}#{opts['sync'] ? '?sync=true' : ''}"
69
- ).put(File.read(wallet.path))
70
- if response.code == '304'
71
- @log.info("#{r}: same version of #{wallet.id} there")
72
- next
73
- end
74
- r.assert_code(200, response)
75
- json = JSON.parse(response.body)['score']
76
- score = Score.parse_json(json)
77
- r.assert_valid_score(score)
78
- raise "Score is too weak #{score}" if score.strength < Score::STRENGTH
79
- @log.info("#{r} accepted #{wallet.id} in #{(Time.now - start).round(2)}s: #{Rainbow(score.value).green}")
80
- total += score.value
69
+ total += push_one(wallet, r, opts)
81
70
  end
82
71
  @log.info("Total score for #{wallet.id} is #{total}")
83
72
  end
73
+
74
+ def push_one(wallet, r, opts)
75
+ if opts['ignore-node'].include?(r.to_s)
76
+ @log.info("#{r} ignored because of --ignore-node")
77
+ return 0
78
+ end
79
+ start = Time.now
80
+ response = r.http(
81
+ "/wallet/#{wallet.id}#{opts['sync'] ? '?sync=true' : ''}"
82
+ ).put(File.read(wallet.path))
83
+ if response.code == '304'
84
+ @log.info("#{r}: same version of #{wallet.id} there")
85
+ return 0
86
+ end
87
+ r.assert_code(200, response)
88
+ json = JSON.parse(response.body)['score']
89
+ score = Score.parse_json(json)
90
+ r.assert_valid_score(score)
91
+ raise "Score is too weak #{score}" if score.strength < Score::STRENGTH
92
+ @log.info("#{r} accepted #{wallet.id} in #{(Time.now - start).round(2)}s: #{Rainbow(score.value).green}")
93
+ score.value
94
+ end
84
95
  end
85
96
  end
@@ -86,7 +86,7 @@ module Zold
86
86
 
87
87
  def push_unsafe(id, body)
88
88
  copies = Copies.new(File.join(@copies, id.to_s))
89
- copies.add(body, 'remote', Remotes::PORT, 0)
89
+ copies.add(body, '0.0.0.0', Remotes::PORT, 0)
90
90
  Fetch.new(
91
91
  wallets: @wallets, remotes: @remotes, copies: copies.root, log: @log
92
92
  ).run(['fetch', id.to_s, "--ignore-node=#{@address}"])
@@ -97,7 +97,7 @@ module Zold
97
97
  copies.remove('remote', Remotes::PORT)
98
98
  Push.new(
99
99
  wallets: @wallets, remotes: @remotes, log: @log
100
- ).run(['push'] + modified.map(&:to_s))
100
+ ).run(['push', "--ignore-node=#{@address}"] + modified.map(&:to_s))
101
101
  modified
102
102
  end
103
103
  end
data/lib/zold/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.11.3'.freeze
26
+ VERSION = '0.11.4'.freeze
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-07 00:00:00.000000000 Z
11
+ date: 2018-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby