lib/zold/node/front.rb in zold-0.17.10 vs lib/zold/node/front.rb in zold-0.18.0
- old
+ new
@@ -103,11 +103,11 @@
end
check_header(Http::SCORE_HEADER) do |header|
if settings.opts['standalone']
settings.log.debug("#{request.url}: we are in standalone mode, won't update remotes")
else
- s = Score.parse_text(header)
+ s = Score.parse(header)
error(400, 'The score is invalid') unless s.valid?
error(400, 'The score is weak') if s.strength < Score::STRENGTH && !settings.opts['ignore-score-weakness']
return if s.value < Front::MIN_SCORE && !settings.opts['ignore-score-weakness']
if settings.address == "#{s.host}:#{s.port}" && !settings.opts['ignore-score-weakness']
error(400, 'Self-requests are prohibited')
@@ -134,11 +134,11 @@
headers['Access-Control-Allow-Origin'] = '*'
headers[Http::SCORE_HEADER] = score.reduced(Front::MIN_SCORE).to_s
headers['X-Zold-Thread'] = Thread.current.object_id.to_s
unless @start.nil?
if Time.now - @start > 1
- settings.log.info("Slow response to #{request.request_method} #{request.url}
+ settings.log.info("Slow response to #{request.request_method} #{request.url} \
from #{request.ip} in #{Age.new(@start, limit: 1)}")
end
headers['X-Zold-Milliseconds'] = ((Time.now - @start) * 1000).round.to_s
end
end
@@ -426,11 +426,15 @@
error do
status 503
e = env['sinatra.error']
content_type 'text/plain'
headers['X-Zold-Error'] = e.message
- settings.log.error(Backtrace.new(e).to_s) unless e.is_a?(SoftError)
+ if e.is_a?(SoftError)
+ settings.log.info("#{request.ip}:#{request.request_method}:#{request.url}: #{e.message}")
+ else
+ settings.log.error(Backtrace.new(e).to_s)
+ end
if e.is_a?(Errno::ENOMEM) && !settings.opts['skip-oom']
settings.log.error("We are running out of memory (#{Size.new(GetProcessMem.new.bytes.to_i)}), \
time to stop; use --skip-oom to never quit")
Front.stop!
end
@@ -450,10 +454,10 @@
# takes a lot of time (when the amount of wallets is big, like 40K). However,
# we must find a way to count them somehow faster.
def total_wallets
return 256 if settings.opts['network'] == Wallet::MAINET
settings.zache.get(:wallets, lifetime: settings.opts['no-cache'] ? 0 : 60) do
- settings.wallets.all.count
+ settings.wallets.count
end
end
def all_remotes
settings.zache.get(:remotes, lifetime: settings.opts['no-cache'] ? 0 : 60) do