lib/zold/node/front.rb in zold-0.3.3 vs lib/zold/node/front.rb in zold-0.3.4
- old
+ new
@@ -19,11 +19,10 @@
# SOFTWARE.
STDOUT.sync = true
require 'slop'
-require 'facter'
require 'json'
require 'sinatra/base'
require 'webrick'
require_relative 'farm'
@@ -32,11 +31,10 @@
require_relative '../wallets'
require_relative '../log'
require_relative '../remotes'
require_relative '../id'
require_relative '../http'
-require_relative '../commands/merge'
# The web front of the node.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
@@ -82,19 +80,12 @@
get '/' do
content_type 'application/json'
JSON.pretty_generate(
version: VERSION,
score: score.to_h,
- platform: {
- uptime: `uptime`.strip,
- # see https://docs.puppet.com/facter/3.3/core_facts.html
- kernel: Facter.value(:kernel),
- processors: Facter.value(:processors)['count']
- },
- wallets: {
- total: wallets.all.count
- },
+ uptime: `uptime`.strip,
+ wallets: wallets.all.count,
farm: settings.farm.to_json,
date: `date --iso-8601=seconds -u`.strip,
age: (Time.now - settings.start) / (60 * 60),
home: 'https://www.zold.io'
)
@@ -116,10 +107,14 @@
id = Id.new(params[:id])
wallet = wallets.find(id)
request.body.rewind
cps = copies(id)
cps.add(request.body.read, 'remote', Remotes::PORT, 0)
+ require_relative '../commands/fetch'
+ Zold::Fetch.new(remotes: remotes, copies: cps.root).run([id.to_s])
+ require_relative '../commands/merge'
Zold::Merge.new(wallets: wallets, copies: cps.root).run([id.to_s])
+ cps.remove('remote', Remotes::PORT)
"Success, #{wallet.id} balance is #{wallet.balance}"
end
get '/remotes' do
content_type 'application/json'