lib/zold/node/front.rb in zold-0.10.7 vs lib/zold/node/front.rb in zold-0.10.8
- old
+ new
@@ -21,11 +21,10 @@
STDOUT.sync = true
require 'json'
require 'sinatra/base'
require 'webrick'
-require 'semantic'
require_relative '../version'
require_relative '../wallet'
require_relative '../log'
require_relative '../id'
require_relative '../http'
@@ -56,15 +55,10 @@
set :remotes, nil? # to be injected at node.rb
set :copies, nil? # to be injected at node.rb
end
before do
- if request.env[Http::VERSION_HEADER] &&
- Semantic::Version.new(VERSION) < Semantic::Version.new(request.env[Http::VERSION_HEADER]) &&
- !settings.remotes.empty? && settings.reboot
- exit(0)
- end
return unless request.env[Http::SCORE_HEADER]
return unless settings.remotes.empty?
s = Score.parse(request.env[Http::SCORE_HEADER])
error(400, 'The score is invalid') unless s.valid?
settings.remotes.add(s.host, s.port) if s.value > 3
@@ -119,15 +113,13 @@
body = request.body.read
if wallet.exists? && File.read(wallet.path) == body
status 304
return
end
- modified = settings.entrance.push(id, body)
+ settings.entrance.push(id, body, sync: !params[:sync].nil?)
JSON.pretty_generate(
version: VERSION,
- score: score.to_h,
- balance: wallet.balance,
- modified: modified.count
+ score: score.to_h
)
end
get '/remotes' do
content_type 'application/json'