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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f141b00987a42599c720d88c575c143a9042ea23742913605b729cbb422336c
4
- data.tar.gz: 07a5846062d9fb519954f95e781c4f21beec04fef41dcb87b4796d28806839a6
3
+ metadata.gz: 6b50bb9c273ecfd4c2a41b71b3c42ae9c05649e6c172eb83a5e70ebd27dbbc71
4
+ data.tar.gz: 43c8777897f0da8778e2a9de36056d70aefe73edd4f16d3411d03a0fc0686225
5
5
  SHA512:
6
- metadata.gz: 80a05326c5e6617cf9d840cde37078e6acaf6b8a88f9c175f711a4704454e7410d4e5dcc63b7433953d278d556aa8ef44bef556ec8ee0a6dd147421b642568dd
7
- data.tar.gz: 464a2a34649948507b5fc321ff419005d2786ae16fa8ec6e2751f50e2b9b2095945a4e25e054748f4144aed07891b7a44420ac5db75bc0830690fee9f1304be8
6
+ metadata.gz: 3c52d1bce704d1a5dc3d0774579292ffc35d1b4bb6679cd71d5b17a60bb0e066b352e12ce266a74a2bbc7882aa348896cafdf662b6a913e73d64819a35a3b5db
7
+ data.tar.gz: 8e74954163cb768ea54a041e8c3b8277113eae58c521b8748c9c1cd0a4c65f43259ac157e4f83f02aff89bd8ebb521e00d55de0b30ffa403901ac6a88ff9fd37
@@ -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
- File.join(home, '.zoldata/async-entrance'),
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
- @queue << { id: Id.new(id), file: file }
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
- loop do
99
- uuid = SecureRandom.uuid
100
- file = File.join(@dir, "#{id}-#{uuid}")
101
- next if File.exist?(file)
102
- IO.write(file, body)
103
- @queue << { id: id, file: file }
104
- @log.debug("Added #{id}/#{Size.new(body.length)} to the queue at pos.#{@queue.size} \
105
- in #{Age.new(start, limit: 0.05)}")
106
- break
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
@@ -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
@@ -25,7 +25,7 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.24.3'
28
+ VERSION = '0.24.4'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
@@ -86,6 +86,7 @@ class FrontTest < Zold::Test
86
86
  '/ledger.json',
87
87
  '/metronome',
88
88
  '/score',
89
+ '/queue',
89
90
  '/trace',
90
91
  '/threads',
91
92
  '/ps'
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.3
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-06 00:00:00.000000000 Z
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.3!
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