zold 0.16.5 → 0.16.6

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: c73944cf9e705895a711529a97a3ab56cd4561724c1b2009416db8355ae9a0e9
4
- data.tar.gz: ece33aa66164e63afebc6f2383d4ad18997fa616abf0311b0956d62ec38f10f6
3
+ metadata.gz: 7190b0b8462533e8c4bd5f97663d78c7b96a2da53d5676c744f6157f99864d1b
4
+ data.tar.gz: 1aa4b614367a48e79cf6ad83fab9018910f4ba09813ea5f2a8e463241d3fddf1
5
5
  SHA512:
6
- metadata.gz: 911f89497f640f092f3f7f2acfc192cb7154be4be191f5a75e4101045bd71432cb7235f31595a1c0290de9ce5848cc60e23e803b447f4a2c1e4e02cd449ae012
7
- data.tar.gz: f98b5bb83459de3cd8c1576e9736a3f873a5a44255e66a0417307804dccb15702f72a9323b6defb43816e121c1388421d25106376cbff54e8fad563ef6dd06ed
6
+ metadata.gz: b74b9b9ac60a0abcb280c81eead4ff9b15fa3b139c7973bf80f4f586bbf15feffbf8c085d9b99e8522febb756ab8014702de294e051817a6a41eb274756ac019
7
+ data.tar.gz: 70f498e4469e72e94d881c7692aa6b7166e76aade1d4b50e60fca1358c859ec65da90af4d57630ef24de009d21eb3540edf5ca1da6694d1a5903480e2e53f1f0
@@ -33,11 +33,14 @@ require_relative 'amount'
33
33
  module Zold
34
34
  # A single tax payment
35
35
  class Tax
36
- # The exact score a wallet can buy in order to pay taxes.
36
+ # The exact score a wallet can/must buy in order to pay taxes.
37
37
  EXACT_SCORE = 8
38
38
 
39
39
  # The maximum allowed amount in one transaction.
40
- MAX_PAYMENT = Amount.new(zld: 1.0)
40
+ # The correct amount should be 1 ZLD, but we allow bigger amounts
41
+ # now since the amount of nodes in the network is still small. When
42
+ # the network grows up, let's put this number back to 1 ZLD.
43
+ MAX_PAYMENT = Amount.new(zld: 16.0)
41
44
 
42
45
  # This is how much we charge per one transaction per hour
43
46
  # of storage. A wallet of 4096 transactions will pay
@@ -48,9 +51,6 @@ module Zold
48
51
  # is bigger than this threshold, nodes must stop accepting PUSH.
49
52
  TRIAL = Amount.new(zld: 1.0)
50
53
 
51
- # For how many days to pay at once.
52
- DAYS_INCREMENT = 64
53
-
54
54
  # Text prefix for taxes details
55
55
  PREFIX = 'TAXES'
56
56
 
@@ -86,7 +86,7 @@ module Zold
86
86
  next if score.strength < Score::STRENGTH
87
87
  next if t.amount > Tax::MAX_PAYMENT
88
88
  t
89
- end.reject(&:nil?).uniq(&:details)
89
+ end.compact.uniq(&:details)
90
90
  paid = scored.empty? ? Amount::ZERO : scored.map(&:amount).inject(&:+)
91
91
  owned = Tax::FEE_TXN_HOUR * txns.count * @wallet.age
92
92
  owned - paid
@@ -25,6 +25,6 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.16.5'
28
+ VERSION = '0.16.6'
29
29
  PROTOCOL = 2
30
30
  end
@@ -70,6 +70,10 @@ module Zold
70
70
  id.to_s
71
71
  end
72
72
 
73
+ def to_text
74
+ (@head.fetch + [''] + @txns.fetch.map(&:to_text)).join("\n")
75
+ end
76
+
73
77
  def network
74
78
  n = @head.fetch[0].strip
75
79
  raise "Invalid network name '#{n}'" unless n =~ /^[a-z]{4,16}$/
@@ -41,11 +41,12 @@ class TestTaxes < Minitest::Test
41
41
  FakeHome.new(log: test_log).run do |home|
42
42
  wallets = home.wallets
43
43
  wallet = home.create_wallet
44
+ fund = Zold::Amount.new(zld: 19.99)
44
45
  wallet.add(
45
46
  Zold::Txn.new(
46
47
  1,
47
48
  Time.now - 24 * 60 * 60 * 365 * 300,
48
- Zold::Amount.new(zld: 19.99),
49
+ fund,
49
50
  'NOPREFIX', Zold::Id.new, '-'
50
51
  )
51
52
  )
@@ -62,12 +63,12 @@ class TestTaxes < Minitest::Test
62
63
  Zold::Taxes.new(wallets: wallets, remotes: remotes, log: test_log).run(
63
64
  ['taxes', '--private-key=fixtures/id_rsa', '--ignore-score-weakness', 'pay', wallet.id.to_s]
64
65
  )
65
- assert_equal(Zold::Amount.new(coins: 81_561_428_951), wallet.balance)
66
+ assert_equal(fund - Zold::Tax::MAX_PAYMENT, wallet.balance)
66
67
  wallet.add(
67
68
  Zold::Txn.new(
68
69
  2,
69
70
  Time.now - 24 * 60 * 60 * 365 * 300,
70
- Zold::Amount.new(zld: 19.99),
71
+ fund,
71
72
  'NOPREFIX', Zold::Id.new, '-'
72
73
  )
73
74
  )
@@ -77,7 +78,7 @@ class TestTaxes < Minitest::Test
77
78
  '--ignore-nodes-absence', 'pay', wallet.id.to_s
78
79
  ]
79
80
  )
80
- assert_equal(Zold::Amount.new(coins: 167_417_825_198), wallet.balance)
81
+ assert_equal(fund + fund - Zold::Tax::MAX_PAYMENT, wallet.balance)
81
82
  end
82
83
  end
83
84
  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.16.5
4
+ version: 0.16.6
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-10-31 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace