zold 0.21.2 → 0.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f59929d65212d37d32f1f98418735329e8194520b349f74c44dca7409ed610e4
4
- data.tar.gz: 3d81af110e3e5835272484ee0a0b420e6f58bd87b9b035faba6a48f2d16f697c
3
+ metadata.gz: b76d686809ed0f518c099bd7afbf901a6e4c8f8d4e23cd8950924a724396a082
4
+ data.tar.gz: 32f523eacb60a2a2c367fccf7ea1e732b1ed4c58ee763cc5effa654c770a5812
5
5
  SHA512:
6
- metadata.gz: 3e88d9c8d354a0181c054a21ddbab493bc8161463112b18436777fa814d714b9ada75c70fe6703f06bfec564a3cd26c6b149496cd33490ce9539a1b498f10d42
7
- data.tar.gz: 7f85bacbe457dc46ee7ae4a46fba59211e16db5e35c951eef6a48e0500ee827c8deb78b91ee7e71c0f750bf335f62e3e2cf6460fc4afdd0772388063ab9b2c9c
6
+ metadata.gz: 34659e7ff4e6e4718dc3832da26e93244c1665acd682c85b369e8c1f9239b44917077fa45f45b03971ea69c2dd2ea06ba7bbaf5a65817f0d5ff03ac72ba4bfa0
7
+ data.tar.gz: aac7c961982d024da032366651a5fd557980d3aa0074628941589b0969e670c78d6ac1a4cb710e56f900c75b351e017d9043083f913af1a9ebae10c4759afff7
data/lib/zold/amount.rb CHANGED
@@ -58,9 +58,14 @@ module Zold
58
58
  @zents
59
59
  end
60
60
 
61
+ # Convert to ZLD and return as a float.
62
+ def to_f
63
+ @zents.to_f / 2**FRACTION
64
+ end
65
+
61
66
  # Convert to ZLD and return as a string. If you need float, you should use <tt>to_f()</tt> later.
62
67
  def to_zld(digits = 2)
63
- format("%0.#{digits}f", @zents.to_f / 2**FRACTION)
68
+ format("%0.#{digits}f", to_f)
64
69
  end
65
70
 
66
71
  def to_s
@@ -29,7 +29,6 @@ require 'rainbow'
29
29
  require 'concurrent/atomics'
30
30
  require 'zold/score'
31
31
  require 'concurrent'
32
- require 'parallel'
33
32
  require_relative 'thread_badge'
34
33
  require_relative 'args'
35
34
  require_relative '../thread_pool'
@@ -25,7 +25,6 @@ require 'slop'
25
25
  require 'json'
26
26
  require 'net/http'
27
27
  require 'concurrent'
28
- require 'parallel'
29
28
  require_relative 'thread_badge'
30
29
  require_relative 'args'
31
30
  require_relative '../thread_pool'
@@ -251,7 +251,9 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
251
251
  digest: wallet.digest,
252
252
  copies: Copies.new(File.join(settings.copies, wallet.id)).all.count,
253
253
  balance: wallet.balance.to_i,
254
- txns: wallet.txns.count
254
+ txns: wallet.txns.count,
255
+ taxes: Tax.new(wallet).paid.to_i,
256
+ debt: Tax.new(wallet).debt.to_i
255
257
  )
256
258
  end
257
259
  end
@@ -22,7 +22,6 @@
22
22
 
23
23
  require 'concurrent'
24
24
  require 'tempfile'
25
- require_relative 'emission'
26
25
  require_relative 'soft_error'
27
26
  require_relative '../log'
28
27
  require_relative '../remotes'
@@ -74,7 +73,6 @@ module Zold
74
73
  if balance.negative? && !wallet.root?
75
74
  raise SoftError, "The balance #{balance} of #{wallet.id} is negative and it's not a root wallet"
76
75
  end
77
- Emission.new(wallet).check
78
76
  tax = Tax.new(wallet)
79
77
  if tax.in_debt?
80
78
  raise SoftError, "Taxes are not paid, can't accept the wallet #{wallet.mnemo}; the debt is #{tax.debt} \
@@ -22,7 +22,6 @@
22
22
 
23
23
  require 'concurrent'
24
24
  require 'tempfile'
25
- require_relative 'emission'
26
25
  require_relative '../log'
27
26
  require_relative '../remotes'
28
27
  require_relative '../copies'
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.21.2'
28
+ VERSION = '0.21.3'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  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.21.2
4
+ version: 0.21.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-07 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -637,7 +637,6 @@ files:
637
637
  - lib/zold/log.rb
638
638
  - lib/zold/metronome.rb
639
639
  - lib/zold/node/async_entrance.rb
640
- - lib/zold/node/emission.rb
641
640
  - lib/zold/node/entrance.rb
642
641
  - lib/zold/node/farm.rb
643
642
  - lib/zold/node/farmers.rb
@@ -693,7 +692,6 @@ files:
693
692
  - test/node/fake_entrance.rb
694
693
  - test/node/fake_node.rb
695
694
  - test/node/test_async_entrance.rb
696
- - test/node/test_emission.rb
697
695
  - test/node/test_entrance.rb
698
696
  - test/node/test_farm.rb
699
697
  - test/node/test_farmers.rb
@@ -746,7 +744,7 @@ licenses:
746
744
  - MIT
747
745
  metadata: {}
748
746
  post_install_message: |-
749
- Thanks for installing Zold 0.21.2!
747
+ Thanks for installing Zold 0.21.3!
750
748
  Study our White Paper: https://papers.zold.io/wp.pdf
751
749
  Read our blog posts: https://blog.zold.io
752
750
  Try ZLD online wallet at: https://wts.zold.io
@@ -802,7 +800,6 @@ test_files:
802
800
  - test/node/fake_entrance.rb
803
801
  - test/node/fake_node.rb
804
802
  - test/node/test_async_entrance.rb
805
- - test/node/test_emission.rb
806
803
  - test/node/test_entrance.rb
807
804
  - test/node/test_farm.rb
808
805
  - test/node/test_farmers.rb
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright (c) 2018-2019 Zerocracy, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
- require 'concurrent'
24
- require 'tempfile'
25
- require_relative '../log'
26
- require_relative '../remotes'
27
- require_relative '../copies'
28
- require_relative '../tax'
29
- require_relative '../commands/merge'
30
- require_relative '../commands/fetch'
31
- require_relative '../commands/push'
32
-
33
- # The emission control point.
34
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
35
- # Copyright:: Copyright (c) 2018 Yegor Bugayenko
36
- # License:: MIT
37
- module Zold
38
- # The emission control poine
39
- class Emission
40
- def initialize(root)
41
- @root = root
42
- end
43
-
44
- def quota
45
- years = @root.age / (24 * 1024)
46
- 1 - (2**-years)
47
- end
48
-
49
- def limit
50
- max = Amount::MAX
51
- Amount.new(zents: (max * quota).to_i)
52
- end
53
-
54
- def check
55
- return unless @root.root?
56
- allowed = limit * -1
57
- balance = @root.balance
58
- raise "The balance #{balance} of the root wallet is too low (max allowed: #{allowed})" if balance < allowed
59
- end
60
- end
61
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright (c) 2018-2019 Zerocracy, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
- require 'minitest/autorun'
24
- require_relative '../fake_home'
25
- require_relative '../test__helper'
26
- require_relative '../../lib/zold/node/emission'
27
- require_relative '../../lib/zold/amount'
28
-
29
- class EmissionTest < Zold::Test
30
- def test_emission
31
- (1..10).each do |year|
32
- FakeHome.new(log: test_log).run do |home|
33
- wallet = home.create_wallet
34
- wallet.add(
35
- Zold::Txn.new(
36
- 1, Time.now - 60 * 24 * 365 * year,
37
- Zold::Amount.new(zld: 39.99),
38
- 'NOPREFIX', Zold::Id::ROOT, '-'
39
- )
40
- )
41
- test_log.info("Year: #{year}, Quota: #{(Zold::Emission.new(wallet).quota * 100).round(2)}%, \
42
- Limit: #{Zold::Emission.new(wallet).limit}")
43
- end
44
- end
45
- end
46
-
47
- def test_emission_passes
48
- FakeHome.new(log: test_log).run do |home|
49
- wallet = home.create_wallet(Zold::Id::ROOT)
50
- wallet.add(
51
- Zold::Txn.new(
52
- 1, Time.now - 60 * 24,
53
- Zold::Amount.new(zld: 10.99),
54
- 'NOPREFIX', Zold::Id.new, '-'
55
- )
56
- )
57
- Zold::Emission.new(wallet).check
58
- end
59
- end
60
- end