zold 0.16.10 → 0.16.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/zold/node/farmers.rb +12 -1
- data/lib/zold/node/front.rb +23 -6
- data/lib/zold/version.rb +1 -1
- data/test/commands/test_clean.rb +6 -0
- data/test/node/test_front.rb +2 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7821595a3b9487ea3138bbee7e70a4f6b960004d7e91a08147f5760a3bd6125c
         | 
| 4 | 
            +
              data.tar.gz: 37450f49b0f2d5e47ba9476ac83d14667eac4cf6b5b65fc10dd142fb8584b6ee
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3d09fdf2081fb1494a1e06b1b28ba8644b5cf4bf7197a6501811dd1f918ca5c7ac5979d1abc6f3b33fd80043922875a87ffe49f51a96c289ed27a2619aef8a6c
         | 
| 7 | 
            +
              data.tar.gz: 53b7bb8a8ded97904c9182f4bcc073b85d22b4b3b1cf1b878111a26c07d5c674880d8890e32bc398a1fb4262471b313d1f6b3ce9b644035d0f65a599b5641a3e
         | 
    
        data/lib/zold/node/farmers.rb
    CHANGED
    
    | @@ -23,6 +23,7 @@ | |
| 23 23 | 
             
            require 'open3'
         | 
| 24 24 | 
             
            require 'backtrace'
         | 
| 25 25 | 
             
            require 'zold/score'
         | 
| 26 | 
            +
            require 'shellwords'
         | 
| 26 27 | 
             
            require_relative '../log'
         | 
| 27 28 | 
             
            require_relative '../age'
         | 
| 28 29 |  | 
| @@ -50,7 +51,17 @@ module Zold | |
| 50 51 | 
             
                    start = Time.now
         | 
| 51 52 | 
             
                    bin = File.expand_path(File.join(File.dirname(__FILE__), '../../../bin/zold'))
         | 
| 52 53 | 
             
                    raise "Zold binary not found at #{bin}" unless File.exist?(bin)
         | 
| 53 | 
            -
                     | 
| 54 | 
            +
                    cmd = [
         | 
| 55 | 
            +
                      'ruby',
         | 
| 56 | 
            +
                      Shellwords.escape(bin),
         | 
| 57 | 
            +
                      '--skip-upgrades',
         | 
| 58 | 
            +
                      Shellwords.escape("--info-thread=#{Thread.current.name}"),
         | 
| 59 | 
            +
                      Shellwords.escape("--info-start=#{Time.now.utc.iso8601}"),
         | 
| 60 | 
            +
                      '--low-priority',
         | 
| 61 | 
            +
                      'next',
         | 
| 62 | 
            +
                      Shellwords.escape(score)
         | 
| 63 | 
            +
                    ].join(' ')
         | 
| 64 | 
            +
                    Open3.popen2e(cmd) do |stdin, stdout, thr|
         | 
| 54 65 | 
             
                      Thread.current.thread_variable_set(:pid, thr.pid.to_s)
         | 
| 55 66 | 
             
                      @log.debug("Scoring started in proc ##{thr.pid} \
         | 
| 56 67 | 
             
            for #{score.value}/#{score.strength} at #{score.host}:#{score.port}")
         | 
    
        data/lib/zold/node/front.rb
    CHANGED
    
    | @@ -26,9 +26,6 @@ require 'eventmachine' | |
| 26 26 | 
             
            require 'thin'
         | 
| 27 27 | 
             
            require 'json'
         | 
| 28 28 | 
             
            require 'sinatra/base'
         | 
| 29 | 
            -
            require 'get_process_mem'
         | 
| 30 | 
            -
            require 'diffy'
         | 
| 31 | 
            -
            require 'usagewatch_ext'
         | 
| 32 29 | 
             
            require 'concurrent'
         | 
| 33 30 | 
             
            require 'backtrace'
         | 
| 34 31 | 
             
            require 'zache'
         | 
| @@ -188,10 +185,19 @@ in #{Age.new(@start, limit: 1)}") | |
| 188 185 | 
             
                    protocol: settings.protocol,
         | 
| 189 186 | 
             
                    score: score.to_h,
         | 
| 190 187 | 
             
                    pid: Process.pid,
         | 
| 191 | 
            -
                     | 
| 192 | 
            -
                     | 
| 188 | 
            +
                    processes: processes_count,
         | 
| 189 | 
            +
                    cpus: settings.zache.get(:cpus) do
         | 
| 190 | 
            +
                      Concurrent.processor_count
         | 
| 191 | 
            +
                    end,
         | 
| 192 | 
            +
                    memory: settings.zache.get(:load, lifetime: 5 * 60) do
         | 
| 193 | 
            +
                      require 'get_process_mem'
         | 
| 194 | 
            +
                      GetProcessMem.new.bytes.to_i
         | 
| 195 | 
            +
                    end,
         | 
| 193 196 | 
             
                    platform: RUBY_PLATFORM,
         | 
| 194 | 
            -
                    load: settings.zache.get(:load, lifetime: 5 * 60)  | 
| 197 | 
            +
                    load: settings.zache.get(:load, lifetime: 5 * 60) do
         | 
| 198 | 
            +
                      require 'usagewatch_ext'
         | 
| 199 | 
            +
                      Usagewatch.uw_load.to_f
         | 
| 200 | 
            +
                    end,
         | 
| 195 201 | 
             
                    threads: "#{Thread.list.select { |t| t.status == 'run' }.count}/#{Thread.list.count}",
         | 
| 196 202 | 
             
                    wallets: total_wallets,
         | 
| 197 203 | 
             
                    remotes: all_remotes.count,
         | 
| @@ -397,6 +403,11 @@ in #{Age.new(@start, limit: 1)}") | |
| 397 403 | 
             
                  ].flatten.join("\n\n")
         | 
| 398 404 | 
             
                end
         | 
| 399 405 |  | 
| 406 | 
            +
                get '/ps' do
         | 
| 407 | 
            +
                  content_type('text/plain')
         | 
| 408 | 
            +
                  `ps ax`
         | 
| 409 | 
            +
                end
         | 
| 410 | 
            +
             | 
| 400 411 | 
             
                not_found do
         | 
| 401 412 | 
             
                  status(404)
         | 
| 402 413 | 
             
                  content_type('text/plain')
         | 
| @@ -442,6 +453,12 @@ in #{Age.new(@start, limit: 1)}") | |
| 442 453 | 
             
                  end
         | 
| 443 454 | 
             
                end
         | 
| 444 455 |  | 
| 456 | 
            +
                def processes_count
         | 
| 457 | 
            +
                  settings.zache.get(:processes, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 458 | 
            +
                    `ps ax | grep zold | wc -l`
         | 
| 459 | 
            +
                  end
         | 
| 460 | 
            +
                end
         | 
| 461 | 
            +
             | 
| 445 462 | 
             
                def score
         | 
| 446 463 | 
             
                  settings.zache.get(:score, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 447 464 | 
             
                    b = settings.farm.best
         | 
    
        data/lib/zold/version.rb
    CHANGED
    
    
    
        data/test/commands/test_clean.rb
    CHANGED
    
    | @@ -44,6 +44,12 @@ class TestClean < Minitest::Test | |
| 44 44 | 
             
                end
         | 
| 45 45 | 
             
              end
         | 
| 46 46 |  | 
| 47 | 
            +
              def test_cleans_empty_wallets
         | 
| 48 | 
            +
                FakeHome.new(log: test_log).run do |home|
         | 
| 49 | 
            +
                  Zold::Clean.new(wallets: home.wallets, copies: File.join(home.dir, 'c'), log: test_log).run(['clean'])
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 47 53 | 
             
              def test_cleans_copies_in_threads
         | 
| 48 54 | 
             
                FakeHome.new(log: test_log).run do |home|
         | 
| 49 55 | 
             
                  wallet = home.create_wallet
         | 
    
        data/test/node/test_front.rb
    CHANGED