zold 0.11.15 → 0.11.16

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
  SHA1:
3
- metadata.gz: ca4077a7a79a8ff6e6cc6ca27ebeda18571a3b7a
4
- data.tar.gz: b5259cec4a2a73e33be07e387466a3b020d30be7
3
+ metadata.gz: 741133a152a47f10deca486c7f68ab98927cb721
4
+ data.tar.gz: eecf1c370e17a0dea43cf298477234f88d6d5813
5
5
  SHA512:
6
- metadata.gz: 4251510624adf3efade782f91cf3ba44bccbd1dfd2561da972253abbd3ab0aff08940c57a66e642a25ea5d42c706167d892babb1871bf8fbe25f684a4fd48da9
7
- data.tar.gz: 27a737d9cccff7cd12c97ff096b69860ee0542f01f2a33908d05bbce0828429d847b6ca12c1d71c03f3273ed83196cfccc18f056a71ec4c972cdef605c829342
6
+ metadata.gz: 8b91d87cf98800345481d0296514a29650df203d345acf732f87246589d92c654612d87f727864b208ba566ed93427c439305c721c1a9801c494a43797fe2c30
7
+ data.tar.gz: 4b15be2214801ddf880f0686494dbe8a93c867ce60d597764aac6c3e1ba8e5232b7e289f357bf1aaf3d82575555cca9aabbb1c3b2f73da490f9116ac077ec9ee
data/README.md CHANGED
@@ -136,6 +136,46 @@ Yes, you can run many nodes with the same wallet ID.
136
136
  Yes, you can use `--threads` command line argument for your node
137
137
  and the number of threads will be as big as you wish.
138
138
 
139
+ ## JSON Details
140
+
141
+ When you open up the front web page of your node, you will see a JSON document
142
+ with a lot of technical details. Here is the explanation of the majority of them:
143
+
144
+ `version` is the current version of the running software.
145
+ The node is supposed to update update itself automatically (if you run it via `zold-nohup`)
146
+ every time it discovers another node with a higher version.
147
+
148
+ `score` is the current score your node is exposing to the network now.
149
+ All other nodes are using this information in order to decide how much
150
+ they can trust your node with the information it provides, about wallets.
151
+ The higher the score, the better.
152
+
153
+ * `value` is the amount of suffixes the score contains; this is the
154
+ number all other nodes rely on.
155
+
156
+ * `host` is the host name of the node, it must be equal to the public
157
+ IP or domain name of the node; it is provided in `--host` command line
158
+ option of `zold-nohup`.
159
+
160
+ * `port` is the TCP port number, which usually is equal to 4096;
161
+ it is provided in `--port` command line option.
162
+
163
+ * `invoice` is the address of your wallet, where the system
164
+ will send you rewards for keeping the node online and some
165
+ users will pay taxes; it is provided in `--invoice` command line option.
166
+
167
+ * `time` is the ISO-8601 UTC date and time of when your node
168
+ started to calculate the score.
169
+
170
+ * `strength` is the amount of tailing zeros the hash contains.
171
+
172
+ * `hash` is the SHA-256 hash of the score text.
173
+
174
+ * `minutes` is the age of the score, in minutes since the moment
175
+ it was created.
176
+
177
+ To be continued...
178
+
139
179
  ## How to Contribute
140
180
 
141
181
  It is a Ruby command line gem. First, install
@@ -33,6 +33,7 @@ zold pay --private-key=id_rsa 0000000000000000 ${invoice} 14.99 'To save the wor
33
33
  zold propagate 0000000000000000
34
34
  zold show
35
35
  zold show 0000000000000000
36
+ zold taxes debt 0000000000000000
36
37
 
37
38
  zold remote show
38
39
  zold push 0000000000000000 --sync
@@ -123,6 +123,7 @@ module Zold
123
123
  sleep(60)
124
124
  require_relative 'remote'
125
125
  Remote.new(remotes: remotes, log: @log, farm: farm).run(%w[remote add b1.zold.io 80 --force])
126
+ Remote.new(remotes: remotes, log: @log, farm: farm).run(%w[remote trim])
126
127
  Remote.new(remotes: remotes, log: @log, farm: farm).run(%w[remote update --reboot])
127
128
  @log.info("Regular update of remote nodes succeeded, total=#{remotes.all.count}")
128
129
  end
@@ -70,7 +70,7 @@ Available options:"
70
70
  when 'debt'
71
71
  raise 'At least one wallet ID is required' unless mine[1]
72
72
  mine[1..-1].each do |id|
73
- debt(@wallets.find(Id.new(id), opts))
73
+ debt(@wallets.find(Id.new(id)), opts)
74
74
  end
75
75
  when 'pay'
76
76
  raise 'At least one wallet ID is required' unless mine[1]
data/lib/zold/patch.rb CHANGED
@@ -56,8 +56,11 @@ module Zold
56
56
  (txn.id <= max ||
57
57
  @txns.find { |t| t.id == txn.id } ||
58
58
  @txns.map(&:amount).inject(&:+) < txn.amount)
59
- unless Signature.new.valid?(@key, wallet.id, txn)
60
- raise "Invalid RSA signature at transaction ##{txn.id} of #{wallet.id}"
59
+ if !txn.amount.negative? && !txn.sign.empty?
60
+ raise "RSA signature is redundant at ##{txn.id} of #{wallet.id}: #{txn.to_text}"
61
+ end
62
+ if txn.amount.negative? && !Signature.new.valid?(@key, wallet.id, txn)
63
+ raise "Invalid RSA signature at transaction ##{txn.id} of #{wallet.id}: #{txn.to_text}"
61
64
  end
62
65
  @txns << txn
63
66
  end
data/lib/zold/txn.rb CHANGED
@@ -83,9 +83,11 @@ module Zold
83
83
  end
84
84
 
85
85
  def inverse(bnf)
86
+ raise 'You can\'t reverse a positive transaction' unless amount.negative?
86
87
  t = clone
87
88
  t.amount = amount * -1
88
89
  t.bnf = bnf
90
+ t.sign = ''
89
91
  t
90
92
  end
91
93
 
data/lib/zold/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.11.15'.freeze
26
+ VERSION = '0.11.16'.freeze
27
27
  end
@@ -0,0 +1,48 @@
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'minitest/autorun'
22
+ require_relative '../test__helper'
23
+ require_relative '../fake_home'
24
+ require_relative '../../lib/zold/amount'
25
+ require_relative '../../lib/zold/commands/propagate'
26
+ require_relative '../../lib/zold/commands/pay'
27
+
28
+ # PROPAGATE test.
29
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
+ # Copyright:: Copyright (c) 2018 Yegor Bugayenko
31
+ # License:: MIT
32
+ class TestPropagate < Minitest::Test
33
+ def test_propagates_wallet
34
+ FakeHome.new.run do |home|
35
+ wallet = home.create_wallet
36
+ friend = home.create_wallet
37
+ amount = Zold::Amount.new(zld: 14.95)
38
+ Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: test_log).run(
39
+ ['pay', wallet.id.to_s, friend.id.to_s, amount.to_zld, '--force', '--private-key=fixtures/id_rsa']
40
+ )
41
+ Zold::Propagate.new(wallets: home.wallets, log: test_log).run(
42
+ ['merge', wallet.id.to_s]
43
+ )
44
+ assert(amount, friend.balance)
45
+ assert('', friend.txns[0].sign)
46
+ end
47
+ end
48
+ 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.11.15
4
+ version: 0.11.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -370,6 +370,7 @@ files:
370
370
  - test/commands/test_merge.rb
371
371
  - test/commands/test_node.rb
372
372
  - test/commands/test_pay.rb
373
+ - test/commands/test_propagate.rb
373
374
  - test/commands/test_push.rb
374
375
  - test/commands/test_remote.rb
375
376
  - test/commands/test_show.rb
@@ -440,6 +441,7 @@ test_files:
440
441
  - test/commands/test_merge.rb
441
442
  - test/commands/test_node.rb
442
443
  - test/commands/test_pay.rb
444
+ - test/commands/test_propagate.rb
443
445
  - test/commands/test_push.rb
444
446
  - test/commands/test_remote.rb
445
447
  - test/commands/test_show.rb