zold 0.24.3 → 0.24.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/commands/node.rb +4 -1
- data/lib/zold/node/async_entrance.rb +31 -10
- data/lib/zold/node/front.rb +6 -0
- data/lib/zold/version.rb +1 -1
- data/test/node/test_front.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b50bb9c273ecfd4c2a41b71b3c42ae9c05649e6c172eb83a5e70ebd27dbbc71
|
4
|
+
data.tar.gz: 43c8777897f0da8778e2a9de36056d70aefe73edd4f16d3411d03a0fc0686225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c52d1bce704d1a5dc3d0774579292ffc35d1b4bb6679cd71d5b17a60bb0e066b352e12ce266a74a2bbc7882aa348896cafdf662b6a913e73d64819a35a3b5db
|
7
|
+
data.tar.gz: 8e74954163cb768ea54a041e8c3b8277113eae58c521b8748c9c1cd0a4c65f43259ac157e4f83f02aff89bd8ebb521e00d55de0b30ffa403901ac6a88ff9fd37
|
data/lib/zold/commands/node.rb
CHANGED
@@ -263,6 +263,9 @@ the node won\'t connect to the network like that; try to do "zold remote reset"
|
|
263
263
|
Front.set(:opts, opts)
|
264
264
|
Front.set(:dump_errors, opts['dump-errors'])
|
265
265
|
Front.set(:port, opts['bind-port'])
|
266
|
+
async_dir = File.join(home, '.zoldata/async-entrance')
|
267
|
+
FileUtils.mkdir_p(async_dir)
|
268
|
+
Front.set(:async_dir, async_dir)
|
266
269
|
Front.set(:node_alias, node_alias(opts, address))
|
267
270
|
entrance = SafeEntrance.new(
|
268
271
|
NoSpamEntrance.new(
|
@@ -283,7 +286,7 @@ the node won\'t connect to the network like that; try to do "zold remote reset"
|
|
283
286
|
ignore_score_weakeness: opts['ignore-score-weakness'],
|
284
287
|
tolerate_edges: opts['tolerate-edges']
|
285
288
|
),
|
286
|
-
|
289
|
+
async_dir,
|
287
290
|
log: @log,
|
288
291
|
queue_limit: opts['queue-limit']
|
289
292
|
),
|
@@ -64,7 +64,11 @@ module Zold
|
|
64
64
|
file = File.join(@dir, f)
|
65
65
|
if /^[0-9a-f]{16}-/.match?(f)
|
66
66
|
id = f.split('-')[0]
|
67
|
-
|
67
|
+
if exists?(id, IO.read(file))
|
68
|
+
@queue << { id: Id.new(id), file: file }
|
69
|
+
else
|
70
|
+
File.delete(file)
|
71
|
+
end
|
68
72
|
else
|
69
73
|
File.delete(file)
|
70
74
|
end
|
@@ -95,21 +99,38 @@ module Zold
|
|
95
99
|
)
|
96
100
|
end
|
97
101
|
start = Time.now
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
102
|
+
unless exists?(id, body)
|
103
|
+
loop do
|
104
|
+
uuid = SecureRandom.uuid
|
105
|
+
file = File.join(@dir, "#{id}-#{uuid}")
|
106
|
+
next if File.exist?(file)
|
107
|
+
IO.write(file, body)
|
108
|
+
@queue << { id: id, file: file }
|
109
|
+
@log.debug("Added #{id}/#{Size.new(body.length)} to the queue at pos.#{@queue.size} \
|
110
|
+
in #{Age.new(start, limit: 0.05)}")
|
111
|
+
break
|
112
|
+
end
|
107
113
|
end
|
108
114
|
[id]
|
109
115
|
end
|
110
116
|
|
111
117
|
private
|
112
118
|
|
119
|
+
# Returns TRUE if a file for this wallet is already in the queue.
|
120
|
+
def exists?(id, body)
|
121
|
+
DirItems.new(@dir).fetch.each do |f|
|
122
|
+
next unless f.start_with?("#{id}-")
|
123
|
+
return true if safe_read(File.join(@dir, f)) == body
|
124
|
+
end
|
125
|
+
false
|
126
|
+
end
|
127
|
+
|
128
|
+
def safe_read(file)
|
129
|
+
IO.read(file)
|
130
|
+
rescue Errno::ENOENT
|
131
|
+
''
|
132
|
+
end
|
133
|
+
|
113
134
|
def take
|
114
135
|
start = Time.now
|
115
136
|
item = @queue.pop
|
data/lib/zold/node/front.rb
CHANGED
@@ -36,6 +36,7 @@ require_relative '../wallet'
|
|
36
36
|
require_relative '../age'
|
37
37
|
require_relative '../copies'
|
38
38
|
require_relative '../log'
|
39
|
+
require_relative '../dir_items'
|
39
40
|
require_relative '../tax'
|
40
41
|
require_relative '../id'
|
41
42
|
require_relative '../http'
|
@@ -80,6 +81,7 @@ module Zold
|
|
80
81
|
set :copies, nil # to be injected at node.rb
|
81
82
|
set :node_alias, nil # to be injected at node.rb
|
82
83
|
set :zache, nil # to be injected at node.rb
|
84
|
+
set :async_dir, nil # to be injected at node.rb
|
83
85
|
end
|
84
86
|
use Rack::Deflater
|
85
87
|
|
@@ -441,6 +443,10 @@ this is not a normal behavior, you may want to report a bug to our GitHub reposi
|
|
441
443
|
processes.join("\n")
|
442
444
|
end
|
443
445
|
|
446
|
+
get '/queue' do
|
447
|
+
DirItems.new(settings.async_dir).fetch.select { |f| /^[0-9a-f]{16}-/.match?(f) }.join("\n")
|
448
|
+
end
|
449
|
+
|
444
450
|
not_found do
|
445
451
|
status(404)
|
446
452
|
content_type('text/plain')
|
data/lib/zold/version.rb
CHANGED
data/test/node/test_front.rb
CHANGED
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.24.
|
4
|
+
version: 0.24.4
|
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-03-
|
11
|
+
date: 2019-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -764,7 +764,7 @@ licenses:
|
|
764
764
|
- MIT
|
765
765
|
metadata: {}
|
766
766
|
post_install_message: |-
|
767
|
-
Thanks for installing Zold 0.24.
|
767
|
+
Thanks for installing Zold 0.24.4!
|
768
768
|
Study our White Paper: https://papers.zold.io/wp.pdf
|
769
769
|
Read our blog posts: https://blog.zold.io
|
770
770
|
Try ZLD online wallet at: https://wts.zold.io
|