zold 0.22.7 → 0.22.8

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
  SHA256:
3
- metadata.gz: c98e24178b0b7da594111beaa66a1461d04aa876efafe8b66baa2862fbef5029
4
- data.tar.gz: a9cf58c9298c540621ec5bf779e3385072142dc9b727a04ea2cca1142e37ef46
3
+ metadata.gz: 42ca9062c455774b1da44e1cec93e5bfaffd9e56669f0c74322a14b96e2c6818
4
+ data.tar.gz: 442934756ba12ed8c947c0331f4852c18529f2afdaf4512e40c6e406a7eb638c
5
5
  SHA512:
6
- metadata.gz: a53f3e0a978221f70fe989b8b2f4230630a34a816a3e9a580b54fb3a8e2b12c4a3cd48a46500b33e41d7ce833bfa52ad78c9aba4410ee56ee6c8a04e4918a4df
7
- data.tar.gz: a511a6b96eb83db16b51c7f8db2b8613bc83d8789a0fbd0b1078c6204e6c4772a76966a4d5a42e4516b02aaafbd90ccb63747b1b7469c39348e70f8874cbc980
6
+ metadata.gz: 328d923df8f83833584ccc83c17e4c589f4830aba44c899e00ca6b47aeeba6e76f834efd7e4a5f7c58589f719805fa6e62763a4938f5872a6468aad312533898
7
+ data.tar.gz: 07ee1516be6327e02b018db91cbc8ad3c1b7fbb0800e4d282e3ad5c98d53e1aaabeb0969fcfe605dfe18d5b7955c2dc88da7d993d0c3ef04016a5ba65d67c5c6
@@ -52,13 +52,15 @@ module Zold
52
52
 
53
53
  def acq(id, exclusive: false)
54
54
  @wallets.acq(id, exclusive: exclusive) do |wallet|
55
- if @queue.size > 256
56
- @log.error("Hungry queue is full with #{@queue.size} wallets, can't add #{id}")
57
- else
58
- @mutex.synchronize do
59
- unless @queue.include?(id)
60
- @queue << id
61
- @log.debug("Hungry queue got #{id}, at the pos no.#{@queue.size - 1}")
55
+ unless wallet.exists?
56
+ if @queue.size > 256
57
+ @log.error("Hungry queue is full with #{@queue.size} wallets, can't add #{id}")
58
+ else
59
+ @mutex.synchronize do
60
+ unless @queue.include?(id)
61
+ @queue << id
62
+ @log.debug("Hungry queue got #{id}, at the pos no.#{@queue.size - 1}")
63
+ end
62
64
  end
63
65
  end
64
66
  end
data/lib/zold/version.rb CHANGED
@@ -25,7 +25,7 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.22.7'
28
+ VERSION = '0.22.8'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
@@ -50,4 +50,21 @@ class TestHungryWallets < Zold::Test
50
50
  assert_requested(get, times: 1)
51
51
  end
52
52
  end
53
+
54
+ def test_doesnt_pull_wallet_if_exists
55
+ FakeHome.new(log: test_log).run do |home|
56
+ pool = Zold::ThreadPool.new('test', log: test_log)
57
+ remotes = home.remotes
58
+ remotes.add('localhost', 4096)
59
+ wallet = home.create_wallet
60
+ get = stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(status: 200)
61
+ wallets = Zold::HungryWallets.new(
62
+ home.wallets, remotes, File.join(home.dir, 'copies'),
63
+ pool, log: test_log
64
+ )
65
+ wallets.acq(wallet.id) { |w| assert(w.exists?) }
66
+ pool.join(2)
67
+ assert_requested(get, times: 0)
68
+ end
69
+ end
53
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.7
4
+ version: 0.22.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -751,7 +751,7 @@ licenses:
751
751
  - MIT
752
752
  metadata: {}
753
753
  post_install_message: |-
754
- Thanks for installing Zold 0.22.7!
754
+ Thanks for installing Zold 0.22.8!
755
755
  Study our White Paper: https://papers.zold.io/wp.pdf
756
756
  Read our blog posts: https://blog.zold.io
757
757
  Try ZLD online wallet at: https://wts.zold.io