zold 0.11.18 → 0.11.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/zold-nohup +4 -4
- data/lib/zold/commands/node.rb +16 -5
- data/lib/zold/commands/pay.rb +10 -0
- data/lib/zold/commands/remote.rb +8 -3
- data/lib/zold/routines.rb +2 -2
- data/lib/zold/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 816289bc1a553b8d68c87fddbc146e3762b51647
|
4
|
+
data.tar.gz: 7cdfbeaa949af0c811e51bc5e7a2b60ab7e9cca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00d3ad3ca4ff95d6fe8166580d3fe91105778c55024d50480ce23934af42972a6509656f8a4a741b16cde8cc0dda0ee7358bfbf1b8111452f7aca3d4fda7e351
|
7
|
+
data.tar.gz: 321040ab95feda603ea6b6a2af005b79268a4242b87d843c2ea52072a182e3c1c11eeca7426bc7a508c842567e881a5c534933979c9b369b188c4dd4209b14f8
|
data/bin/zold-nohup
CHANGED
@@ -55,7 +55,7 @@ end
|
|
55
55
|
|
56
56
|
def exec(cmd)
|
57
57
|
Open3.popen2e(cmd) do |stdin, stdout, thr|
|
58
|
-
log("Started: #{cmd}")
|
58
|
+
log("Started: #{cmd}\n")
|
59
59
|
stdin.close
|
60
60
|
loop do
|
61
61
|
line = stdout.gets
|
@@ -63,7 +63,7 @@ def exec(cmd)
|
|
63
63
|
log(line)
|
64
64
|
end
|
65
65
|
code = thr.value.exitstatus
|
66
|
-
log("Exit code is #{code}: #{cmd}")
|
66
|
+
log("Exit code is #{code}: #{cmd}\n")
|
67
67
|
raise "Exit code #{code} (non zero)" unless code.zero?
|
68
68
|
end
|
69
69
|
end
|
@@ -72,10 +72,10 @@ File.delete($opts['log-file']) if File.exist?($opts['log-file']) && !$opts['skip
|
|
72
72
|
|
73
73
|
$pid = fork do
|
74
74
|
Signal.trap('HUP') do
|
75
|
-
|
75
|
+
log('Received HUP, ignoring...')
|
76
76
|
end
|
77
77
|
Signal.trap('TERM') do
|
78
|
-
|
78
|
+
log('Received TERM, terminating...')
|
79
79
|
exit(-1)
|
80
80
|
end
|
81
81
|
loop do
|
data/lib/zold/commands/node.rb
CHANGED
@@ -27,6 +27,7 @@ require_relative '../verbose_thread'
|
|
27
27
|
require_relative '../node/entrance'
|
28
28
|
require_relative '../node/front'
|
29
29
|
require_relative '../node/farm'
|
30
|
+
require_relative 'pull'
|
30
31
|
require_relative 'push'
|
31
32
|
require_relative 'pay'
|
32
33
|
|
@@ -52,8 +53,8 @@ module Zold
|
|
52
53
|
o.integer '--bind-port',
|
53
54
|
"TCP port to listen on (default: #{Remotes::PORT})",
|
54
55
|
default: Remotes::PORT
|
55
|
-
o.string '--host',
|
56
|
-
default:
|
56
|
+
o.string '--host', "Host name (default: #{ip})",
|
57
|
+
default: ip
|
57
58
|
o.string '--home', 'Home directory (default: .)',
|
58
59
|
default: Dir.pwd
|
59
60
|
o.integer '--strength',
|
@@ -128,7 +129,7 @@ module Zold
|
|
128
129
|
threads: opts[:threads], strength: opts[:strength]
|
129
130
|
)
|
130
131
|
Front.set(:farm, farm)
|
131
|
-
routines = routines(wallets, remotes, farm, opts)
|
132
|
+
routines = routines(wallets, remotes, copies, farm, opts)
|
132
133
|
@log.debug("Starting up the web front at http://#{opts[:host]}:#{opts[:port]}...")
|
133
134
|
begin
|
134
135
|
Front.run!
|
@@ -140,7 +141,7 @@ module Zold
|
|
140
141
|
|
141
142
|
private
|
142
143
|
|
143
|
-
def routines(wallets, remotes, farm, opts)
|
144
|
+
def routines(wallets, remotes, copies, farm, opts)
|
144
145
|
routines = Routines.new(@log)
|
145
146
|
routines.add do
|
146
147
|
require_relative 'remote'
|
@@ -151,7 +152,7 @@ module Zold
|
|
151
152
|
)
|
152
153
|
end
|
153
154
|
if opts['bonus-wallet']
|
154
|
-
routines.add do
|
155
|
+
routines.add(60) do
|
155
156
|
require_relative 'remote'
|
156
157
|
winners = Remote.new(remotes: remotes, log: @log, farm: farm).run(
|
157
158
|
['remote', 'elect', opts['bonus-wallet'], '--private-key', opts['private-key']]
|
@@ -160,6 +161,9 @@ module Zold
|
|
160
161
|
@log.info('No winners elected, won\'t pay any bonuses')
|
161
162
|
else
|
162
163
|
winners.each do |score|
|
164
|
+
Pull.new(wallets: wallets, remotes: remotes, copies: copies, log: @log).run(
|
165
|
+
['pull', opts['bonus-wallet']]
|
166
|
+
)
|
163
167
|
Pay.new(wallets: wallets, remotes: remotes, log: @log).run(
|
164
168
|
[
|
165
169
|
'pay', opts['bonus-wallet'], score.invoice, opts['bonus-amount'],
|
@@ -177,6 +181,13 @@ module Zold
|
|
177
181
|
routines
|
178
182
|
end
|
179
183
|
|
184
|
+
def ip
|
185
|
+
addr = Socket.ip_address_list.detect do |i|
|
186
|
+
i.ipv4? && !i.ipv4_loopback? && !i.ipv4_multicast? && !i.ipv4_private?
|
187
|
+
end
|
188
|
+
addr.nil? ? '127.0.0.1' : addr.ip_address
|
189
|
+
end
|
190
|
+
|
180
191
|
# Fake logging facility for Webrick
|
181
192
|
class WebrickLog
|
182
193
|
def initialize(log)
|
data/lib/zold/commands/pay.rb
CHANGED
@@ -21,6 +21,8 @@
|
|
21
21
|
require 'slop'
|
22
22
|
require 'rainbow'
|
23
23
|
require_relative 'args'
|
24
|
+
require_relative '../id'
|
25
|
+
require_relative '../amount'
|
24
26
|
require_relative '../log'
|
25
27
|
|
26
28
|
# PAY command.
|
@@ -55,6 +57,9 @@ Available options:"
|
|
55
57
|
o.bool '--dont-pay-taxes',
|
56
58
|
'Don\'t pay taxes even if the wallet is in debt',
|
57
59
|
default: false
|
60
|
+
o.bool '--dont-propagate',
|
61
|
+
'Don\'t propagate the paying wallet after successful pay',
|
62
|
+
default: false
|
58
63
|
o.bool '--help', 'Print instructions'
|
59
64
|
end
|
60
65
|
mine = Args.new(opts, @log).take || return
|
@@ -72,10 +77,15 @@ Available options:"
|
|
72
77
|
amount = Amount.new(zld: mine[2].to_f)
|
73
78
|
details = mine[3] || '-'
|
74
79
|
if Tax.new(from).in_debt? && !opts['dont-pay-taxes']
|
80
|
+
require_relative 'taxes'
|
75
81
|
Taxes.new(wallets: @wallets, remotes: @remotes, log: @log).run(
|
76
82
|
['taxes', "--private-key=#{opts['private-key']}", id.to_s]
|
77
83
|
)
|
78
84
|
end
|
85
|
+
unless opts['dont-propagate']
|
86
|
+
require_relative 'propagate'
|
87
|
+
Propagate.new(wallets: @wallets, log: @log).run(['propagate', id.to_s])
|
88
|
+
end
|
79
89
|
pay(from, invoice, amount, details, opts)
|
80
90
|
end
|
81
91
|
|
data/lib/zold/commands/remote.rb
CHANGED
@@ -185,10 +185,15 @@ Available options:"
|
|
185
185
|
r.assert_score_ownership(score)
|
186
186
|
r.assert_score_strength(score) unless opts['ignore-score-weakness']
|
187
187
|
@remotes.rescore(score.host, score.port, score.value)
|
188
|
-
if
|
189
|
-
|
188
|
+
if Semantic::Version.new(VERSION) < Semantic::Version.new(json['version'])
|
189
|
+
if opts['reboot']
|
190
|
+
@log.info("#{r}: their version #{json['version']} is higher than mine #{VERSION}, reboot! \
|
190
191
|
(use --never-reboot to avoid this from happening)")
|
191
|
-
|
192
|
+
exit(0)
|
193
|
+
else
|
194
|
+
@log.info("#{r}: their version #{json['version']} is higher than mine #{VERSION}, \
|
195
|
+
it's recommended to reboot, but I don't do it because of --never-reboot")
|
196
|
+
end
|
192
197
|
end
|
193
198
|
if deep
|
194
199
|
json['all'].each do |s|
|
data/lib/zold/routines.rb
CHANGED
@@ -33,13 +33,13 @@ module Zold
|
|
33
33
|
@threads = []
|
34
34
|
end
|
35
35
|
|
36
|
-
def add(
|
36
|
+
def add(minutes = 1)
|
37
37
|
@threads << Thread.start do
|
38
38
|
VerboseThread.new(@log).run(true) do
|
39
39
|
Thread.current.name = 'routines'
|
40
40
|
count = 0
|
41
41
|
loop do
|
42
|
-
sleep(
|
42
|
+
sleep(minutes * 60)
|
43
43
|
yield count
|
44
44
|
count += 1
|
45
45
|
end
|
data/lib/zold/version.rb
CHANGED