lib/zold/node/front.rb in zold-0.16.7 vs lib/zold/node/front.rb in zold-0.16.8
- old
+ new
@@ -29,19 +29,19 @@
require 'get_process_mem'
require 'diffy'
require 'usagewatch_ext'
require 'concurrent'
require 'backtrace'
+require 'zache'
require_relative '../version'
require_relative '../size'
require_relative '../wallet'
require_relative '../age'
require_relative '../copies'
require_relative '../log'
require_relative '../id'
require_relative '../http'
-require_relative '../cache'
# The web front of the node.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
@@ -75,11 +75,11 @@
set :network, 'test' # to be injected at node.rb
set :wallets, nil? # to be injected at node.rb
set :remotes, nil? # to be injected at node.rb
set :copies, nil? # to be injected at node.rb
set :node_alias, nil? # to be injected at node.rb
- set :cache, Cache.new
+ set :zache, Zache.new
end
use Rack::Deflater
before do
Thread.current.thread_variable_set(:uri, request.url)
@@ -185,14 +185,14 @@
alias: settings.node_alias,
network: settings.network,
protocol: settings.protocol,
score: score.to_h,
pid: Process.pid,
- cpus: settings.cache.get(:cpus) { Concurrent.processor_count },
+ cpus: settings.zache.get(:cpus) { Concurrent.processor_count },
memory: GetProcessMem.new.bytes.to_i,
platform: RUBY_PLATFORM,
- load: settings.cache.get(:load, lifetime: 5 * 60) { Usagewatch.uw_load.to_f },
+ load: settings.zache.get(:load, lifetime: 5 * 60) { Usagewatch.uw_load.to_f },
threads: "#{Thread.list.select { |t| t.status == 'run' }.count}/#{Thread.list.count}",
wallets: total_wallets,
remotes: all_remotes.count,
nscore: all_remotes.map { |r| r[:score] }.inject(&:+) || 0,
farm: settings.farm.to_json,
@@ -433,16 +433,16 @@
return 256 if settings.network == Wallet::MAIN_NETWORK
settings.wallets.all.count
end
def all_remotes
- settings.cache.get(:remotes, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
+ settings.zache.get(:remotes, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
settings.remotes.all
end
end
def score
- settings.cache.get(:score, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
+ settings.zache.get(:score, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
b = settings.farm.best
raise 'Score is empty, there is something wrong with the Farm!' if b.empty?
b[0]
end
end