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 +4 -4
- data/lib/zold/hungry_wallets.rb +9 -7
- data/lib/zold/version.rb +1 -1
- data/test/test_hungry_wallets.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42ca9062c455774b1da44e1cec93e5bfaffd9e56669f0c74322a14b96e2c6818
|
4
|
+
data.tar.gz: 442934756ba12ed8c947c0331f4852c18529f2afdaf4512e40c6e406a7eb638c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 328d923df8f83833584ccc83c17e4c589f4830aba44c899e00ca6b47aeeba6e76f834efd7e4a5f7c58589f719805fa6e62763a4938f5872a6468aad312533898
|
7
|
+
data.tar.gz: 07ee1516be6327e02b018db91cbc8ad3c1b7fbb0800e4d282e3ad5c98d53e1aaabeb0969fcfe605dfe18d5b7955c2dc88da7d993d0c3ef04016a5ba65d67c5c6
|
data/lib/zold/hungry_wallets.rb
CHANGED
@@ -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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
@queue
|
61
|
-
|
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
data/test/test_hungry_wallets.rb
CHANGED
@@ -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.
|
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.
|
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
|