zold 0.16.28 → 0.16.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/cached_wallets.rb +4 -1
- data/lib/zold/commands/merge.rb +12 -13
- data/lib/zold/node/async_entrance.rb +1 -1
- data/lib/zold/node/front.rb +0 -4
- data/lib/zold/sync_wallets.rb +1 -2
- data/lib/zold/version.rb +1 -1
- data/test/node/test_entrance.rb +1 -1
- data/test/test_cached_wallets.rb +22 -2
- data/test/test_wallet.rb +20 -0
- data/zold.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c056002cff9a87ffe6f778a5177ffb939b91f06c509755fff6837709085c24db
|
4
|
+
data.tar.gz: e8a1593eb1356bc2252ba0b142d335a30b06447de722cecfd0699508689972c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d098da93208df8f1698179e653504cccb907e8392f3fbcd88183e50a8e24cada09f54945cbe9f26fc6821d2555e2b73bcbea16f8fbe6e8ec4af7cc68f3b50d6
|
7
|
+
data.tar.gz: 9aaa767e15bf74b011c0c2e07b7e13b2f282fa16802beeafb508ebc045b8f3bc709a3d7ddf8b17b933bfdbb664af655ab2e16348b150086b6ffd4be5fa0cfda3
|
data/lib/zold/cached_wallets.rb
CHANGED
@@ -55,7 +55,10 @@ module Zold
|
|
55
55
|
|
56
56
|
def acq(id, exclusive: false)
|
57
57
|
@wallets.acq(id, exclusive: exclusive) do |wallet|
|
58
|
-
|
58
|
+
c = @zache.get(id.to_s, lifetime: 5 * 60) { wallet }
|
59
|
+
res = yield c
|
60
|
+
c.flush if exclusive
|
61
|
+
res
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|
data/lib/zold/commands/merge.rb
CHANGED
@@ -83,24 +83,23 @@ Available options:"
|
|
83
83
|
merge_one(opts, patch, wallet, name)
|
84
84
|
score += c[:score]
|
85
85
|
end
|
86
|
-
|
87
|
-
|
88
|
-
if
|
89
|
-
merge_one(opts, patch,
|
86
|
+
start = Time.now
|
87
|
+
@wallets.acq(id) do |w|
|
88
|
+
if w.exists?
|
89
|
+
merge_one(opts, patch, w, 'localhost')
|
90
90
|
@log.debug("Local copy of #{id} merged in #{Age.new(start)}: #{patch}")
|
91
91
|
else
|
92
92
|
@log.debug("Local copy of #{id} is absent, nothing to merge")
|
93
93
|
end
|
94
|
-
modified = patch.save(wallet.path, overwrite: true)
|
95
|
-
wallet.flush
|
96
|
-
if modified
|
97
|
-
@log.info("#{cps.count} copies with the total score of #{score} successfully merged \
|
98
|
-
into #{wallet.mnemo} in #{Age.new(start, limit: 0.1 + cps.count * 0.01)}")
|
99
|
-
else
|
100
|
-
@log.info("Nothing changed in #{wallet.id} after merge of #{cps.count} copies")
|
101
|
-
end
|
102
|
-
modified
|
103
94
|
end
|
95
|
+
modified = @wallets.acq(id, exclusive: true) { |w| patch.save(w.path, overwrite: true) }
|
96
|
+
if modified
|
97
|
+
@log.info("#{cps.count} copies with the total score of #{score} successfully merged \
|
98
|
+
into #{@wallets.acq(id, &:mnemo)} in #{Age.new(start, limit: 0.1 + cps.count * 0.01)}")
|
99
|
+
else
|
100
|
+
@log.info("Nothing changed in #{id} after merge of #{cps.count} copies")
|
101
|
+
end
|
102
|
+
modified
|
104
103
|
end
|
105
104
|
|
106
105
|
def merge_one(opts, patch, wallet, name)
|
@@ -87,7 +87,7 @@ module Zold
|
|
87
87
|
IO.write(file, body)
|
88
88
|
@queue << { id: id, file: file }
|
89
89
|
@log.debug("Added #{id}/#{Size.new(body.length)} to the queue at pos.#{@queue.size} \
|
90
|
-
in #{Age.new(start, limit: 0.05)}
|
90
|
+
in #{Age.new(start, limit: 0.05)}")
|
91
91
|
break
|
92
92
|
end
|
93
93
|
[id]
|
data/lib/zold/node/front.rb
CHANGED
data/lib/zold/sync_wallets.rb
CHANGED
@@ -49,8 +49,7 @@ module Zold
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def acq(id, exclusive: false)
|
52
|
-
|
53
|
-
@wallets.acq(id) do |wallet|
|
52
|
+
@wallets.acq(id, exclusive: exclusive) do |wallet|
|
54
53
|
Futex.new(wallet.path, log: @log).open(exclusive) do
|
55
54
|
yield wallet
|
56
55
|
end
|
data/lib/zold/version.rb
CHANGED
data/test/node/test_entrance.rb
CHANGED
@@ -55,9 +55,9 @@ class TestEntrance < Zold::Test
|
|
55
55
|
target = home.create_wallet(tid)
|
56
56
|
e = Zold::Entrance.new(home.wallets, home.remotes, home.copies(source).root, 'x', log: test_log)
|
57
57
|
modified = e.push(source.id, body)
|
58
|
+
assert_equal(2, modified.count)
|
58
59
|
assert_equal(Zold::Amount.new(zld: -19.99), source.balance)
|
59
60
|
assert_equal(Zold::Amount.new(zld: 19.99), target.balance)
|
60
|
-
assert_equal(2, modified.count)
|
61
61
|
assert(modified.include?(sid))
|
62
62
|
assert(modified.include?(tid))
|
63
63
|
end
|
data/test/test_cached_wallets.rb
CHANGED
@@ -36,8 +36,8 @@ require_relative '../lib/zold/amount'
|
|
36
36
|
# License:: MIT
|
37
37
|
class TestCachedWallets < Zold::Test
|
38
38
|
def test_adds_wallet
|
39
|
-
|
40
|
-
wallets = Zold::CachedWallets.new(
|
39
|
+
Dir.mktmpdir do |dir|
|
40
|
+
wallets = Zold::CachedWallets.new(Zold::Wallets.new(dir))
|
41
41
|
id = Zold::Id.new
|
42
42
|
first = nil
|
43
43
|
wallets.acq(id, exclusive: true) do |wallet|
|
@@ -50,4 +50,24 @@ class TestCachedWallets < Zold::Test
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
def test_flushes_correctly
|
55
|
+
Dir.mktmpdir do |dir|
|
56
|
+
wallets = Zold::CachedWallets.new(Zold::Wallets.new(dir))
|
57
|
+
id = Zold::Id.new
|
58
|
+
key = Zold::Key.new(file: 'fixtures/id_rsa')
|
59
|
+
body = wallets.acq(id, exclusive: true) do |wallet|
|
60
|
+
wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
|
61
|
+
IO.read(wallet.path)
|
62
|
+
end
|
63
|
+
wallets.acq(id, exclusive: true) do |wallet|
|
64
|
+
wallet.sub(Zold::Amount.new(zld: 1.0), "NOPREFIX@#{Zold::Id.new}", key)
|
65
|
+
end
|
66
|
+
assert_equal(1, wallets.acq(id, &:txns).count)
|
67
|
+
wallets.acq(id, exclusive: true) do |wallet|
|
68
|
+
IO.write(wallet.path, body)
|
69
|
+
end
|
70
|
+
assert_equal(0, wallets.acq(id, &:txns).count)
|
71
|
+
end
|
72
|
+
end
|
53
73
|
end
|
data/test/test_wallet.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'minitest/autorun'
|
24
|
+
require_relative 'test__helper'
|
24
25
|
require_relative 'fake_home'
|
25
26
|
require_relative '../lib/zold/key'
|
26
27
|
require_relative '../lib/zold/age'
|
@@ -185,6 +186,25 @@ class TestWallet < Zold::Test
|
|
185
186
|
end
|
186
187
|
end
|
187
188
|
|
189
|
+
def test_flushes_and_reads_again
|
190
|
+
FakeHome.new(log: test_log).run do |home|
|
191
|
+
wallet = home.create_wallet
|
192
|
+
wallet.add(
|
193
|
+
Zold::Txn.new(
|
194
|
+
1,
|
195
|
+
Time.now,
|
196
|
+
Zold::Amount.new(zld: 1.99),
|
197
|
+
'NOPREFIX', Zold::Id.new, '-'
|
198
|
+
)
|
199
|
+
)
|
200
|
+
assert_equal(1, wallet.txns.count)
|
201
|
+
assert_equal('test', wallet.network)
|
202
|
+
wallet.flush
|
203
|
+
assert_equal(1, wallet.txns.count)
|
204
|
+
assert_equal('test', wallet.network)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
188
208
|
def test_returns_modified_time
|
189
209
|
FakeHome.new(log: test_log).run do |home|
|
190
210
|
wallet = home.create_wallet
|
data/zold.gemspec
CHANGED
@@ -62,10 +62,10 @@ and suggests a different architecture for digital wallet maintenance.'
|
|
62
62
|
s.rdoc_options = ['--charset=UTF-8']
|
63
63
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
64
64
|
s.add_runtime_dependency 'backtrace', '0.3.0'
|
65
|
-
s.add_runtime_dependency 'concurrent-ruby', '1.1.
|
65
|
+
s.add_runtime_dependency 'concurrent-ruby', '1.1.3'
|
66
66
|
s.add_runtime_dependency 'cucumber', '3.1.2' # has to stay here for Heroku
|
67
67
|
s.add_runtime_dependency 'diffy', '3.2.1'
|
68
|
-
s.add_runtime_dependency 'futex', '0.4.
|
68
|
+
s.add_runtime_dependency 'futex', '0.4.3'
|
69
69
|
s.add_runtime_dependency 'get_process_mem', '0.2.3'
|
70
70
|
s.add_runtime_dependency 'json', '2.1.0'
|
71
71
|
s.add_runtime_dependency 'memory_profiler', '0.9.12'
|
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.16.
|
4
|
+
version: 0.16.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.
|
33
|
+
version: 1.1.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.1.
|
40
|
+
version: 1.1.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: cucumber
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.4.
|
75
|
+
version: 0.4.3
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.4.
|
82
|
+
version: 0.4.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: get_process_mem
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -697,7 +697,7 @@ licenses:
|
|
697
697
|
- MIT
|
698
698
|
metadata: {}
|
699
699
|
post_install_message: |-
|
700
|
-
Thanks for installing Zold 0.16.
|
700
|
+
Thanks for installing Zold 0.16.29!
|
701
701
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
702
702
|
Read our blog posts: https://blog.zold.io
|
703
703
|
Try online wallet at: https://wts.zold.io
|