zold 0.16.18 → 0.16.19
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/fixtures/scripts/redeploy-on-upgrade.sh +8 -1
- data/lib/zold/commands/list.rb +1 -1
- data/lib/zold/commands/node.rb +1 -7
- data/lib/zold/commands/push.rb +3 -1
- data/lib/zold/commands/remote.rb +7 -0
- data/lib/zold/node/front.rb +56 -56
- data/lib/zold/version.rb +1 -1
- data/test/node/fake_node.rb +1 -1
- data/test/node/test_front.rb +2 -2
- data/test/test_zold.rb +1 -2
- data/zold.gemspec +1 -1
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f5c735ab0c917e4b346f598206c82a224a81caf5e6e3629d73203cb918bd6200
         | 
| 4 | 
            +
              data.tar.gz: 41f2241f736aab555d0fd2a32481814c2142121339488a7e6269506a398204d2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8b477ea12a0c08aff12a68c5f07af44e13ebd131c0c156b9cde6fcf62da81fe21ffab32c3dc13483ec330a0f8a01ad8efcb67bc8612b772ea812bff5fe5b2a8a
         | 
| 7 | 
            +
              data.tar.gz: 2eed2bff0ee50b4136088e2ad3a8b7c1ca80cffe02115f25891eeb6d45129bc590387134afbe22ed3bce1bf8c944c507aff07aa4708d5e7395b5b90998c2d045
         | 
| @@ -7,7 +7,7 @@ function start_node { | |
| 7 7 | 
             
              zold node $3 --nohup --nohup-command='touch restarted' --nohup-log=log --nohup-max-cycles=0 --nohup-log-truncate=10240 \
         | 
| 8 8 | 
             
                --expose-version=$2 --save-pid=pid --routine-immediately \
         | 
| 9 9 | 
             
                --verbose --trace --invoice=REDEPLOY@ffffffffffffffff \
         | 
| 10 | 
            -
                --host=localhost --port=$1 --bind-port=$1 --threads= | 
| 10 | 
            +
                --host=localhost --port=$1 --bind-port=$1 --threads=1 --strength=20 > /dev/null 2>&1
         | 
| 11 11 | 
             
              wait_for_port $1
         | 
| 12 12 | 
             
              cat pid
         | 
| 13 13 | 
             
              cd ..
         | 
| @@ -18,12 +18,19 @@ primary=$(start_node ${high} 9.9.9 --standalone) | |
| 18 18 |  | 
| 19 19 | 
             
            low=$(reserve_port)
         | 
| 20 20 | 
             
            secondary=$(start_node ${low} 1.1.1)
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            zold remote clean
         | 
| 21 23 | 
             
            zold remote add localhost ${high} --home=${low} --skip-ping
         | 
| 22 24 |  | 
| 23 25 | 
             
            trap "halt_nodes ${high}" EXIT
         | 
| 24 26 |  | 
| 25 27 | 
             
            wait_for_file ${low}/restarted
         | 
| 26 28 |  | 
| 29 | 
            +
            if [ `ps ax | grep zold | grep "${low}"` -eq '' ]; then
         | 
| 30 | 
            +
              echo "The score finder process is still there, it's a bug"
         | 
| 31 | 
            +
              exit -1
         | 
| 32 | 
            +
            fi
         | 
| 33 | 
            +
             | 
| 27 34 | 
             
            echo "High node logs (port ${high}):"
         | 
| 28 35 | 
             
            cat ${high}/log
         | 
| 29 36 | 
             
            echo "Low node logs (port ${low}):"
         | 
    
        data/lib/zold/commands/list.rb
    CHANGED
    
    
    
        data/lib/zold/commands/node.rb
    CHANGED
    
    | @@ -168,12 +168,8 @@ module Zold | |
| 168 168 | 
             
                  Front.set(:logger, @log)
         | 
| 169 169 | 
             
                  Front.set(:trace, @log)
         | 
| 170 170 | 
             
                  Front.set(:nohup_log, opts['nohup-log']) if opts['nohup-log']
         | 
| 171 | 
            -
                  Front.set(:version, opts['expose-version'])
         | 
| 172 171 | 
             
                  Front.set(:protocol, Zold::PROTOCOL)
         | 
| 173 172 | 
             
                  Front.set(:logging, @log.debug?)
         | 
| 174 | 
            -
                  Front.set(:halt, opts['halt-code'])
         | 
| 175 | 
            -
                  Front.set(:disable_push, opts['disable-push'])
         | 
| 176 | 
            -
                  Front.set(:disable_fetch, opts['disable-fetch'])
         | 
| 177 173 | 
             
                  home = File.expand_path(opts['home'])
         | 
| 178 174 | 
             
                  Front.set(:home, home)
         | 
| 179 175 | 
             
                  @log.info("Time: #{Time.now.utc.iso8601}")
         | 
| @@ -197,16 +193,14 @@ module Zold | |
| 197 193 | 
             
                    Zold::Remote.new(remotes: @remotes).run(['remote', 'remove', host, port.to_s])
         | 
| 198 194 | 
             
                    @log.info("Removed current node (#{address}) from list of remotes")
         | 
| 199 195 | 
             
                  end
         | 
| 200 | 
            -
                  Front.set(:ignore_score_weakness, opts['ignore-score-weakness'])
         | 
| 201 | 
            -
                  Front.set(:network, opts['network'])
         | 
| 202 196 | 
             
                  Front.set(:wallets, @wallets)
         | 
| 203 197 | 
             
                  Front.set(:remotes, @remotes)
         | 
| 204 198 | 
             
                  Front.set(:copies, @copies)
         | 
| 205 199 | 
             
                  Front.set(:address, address)
         | 
| 206 200 | 
             
                  Front.set(:root, home)
         | 
| 201 | 
            +
                  Front.set(:opts, opts)
         | 
| 207 202 | 
             
                  Front.set(:dump_errors, opts['dump-errors'])
         | 
| 208 203 | 
             
                  Front.set(:port, opts['bind-port'])
         | 
| 209 | 
            -
                  Front.set(:reboot, !opts['never-reboot'])
         | 
| 210 204 | 
             
                  node_alias = opts[:alias] || address
         | 
| 211 205 | 
             
                  unless node_alias.eql?(address) || node_alias =~ /^[A-Za-z0-9]{4,16}$/
         | 
| 212 206 | 
             
                    raise "Alias should be a 4 to 16 char long alphanumeric string: #{node_alias}"
         | 
    
        data/lib/zold/commands/push.rb
    CHANGED
    
    | @@ -104,8 +104,10 @@ total score for #{id} is #{total}") | |
| 104 104 | 
             
                    r.assert_valid_score(score)
         | 
| 105 105 | 
             
                    r.assert_score_ownership(score)
         | 
| 106 106 | 
             
                    r.assert_score_strength(score) unless opts['ignore-score-weakness']
         | 
| 107 | 
            -
                    @log.info | 
| 107 | 
            +
                    if @log.info?
         | 
| 108 | 
            +
                      @log.info("#{r} accepted #{wallet.mnemo} in #{Age.new(start, limit: 4)}: \
         | 
| 108 109 | 
             
            #{Rainbow(score.value).green} (#{json['version']})")
         | 
| 110 | 
            +
                    end
         | 
| 109 111 | 
             
                    score.value
         | 
| 110 112 | 
             
                  end
         | 
| 111 113 | 
             
                end
         | 
    
        data/lib/zold/commands/remote.rb
    CHANGED
    
    | @@ -87,6 +87,9 @@ Available options:" | |
| 87 87 | 
             
                    o.array '--ignore-node',
         | 
| 88 88 | 
             
                      'Ignore this node and never add it to the list',
         | 
| 89 89 | 
             
                      default: []
         | 
| 90 | 
            +
                    o.bool '--ignore-if-exists',
         | 
| 91 | 
            +
                      'Ignore the node while adding if it already exists in the list',
         | 
| 92 | 
            +
                      default: false
         | 
| 90 93 | 
             
                    o.integer '--min-score',
         | 
| 91 94 | 
             
                      "The minimum score required for winning the election (default: #{Tax::EXACT_SCORE})",
         | 
| 92 95 | 
             
                      default: Tax::EXACT_SCORE
         | 
| @@ -179,6 +182,10 @@ Available options:" | |
| 179 182 | 
             
                    @log.info("#{host}:#{port} won't be added since it's in the --ignore-node list")
         | 
| 180 183 | 
             
                    return
         | 
| 181 184 | 
             
                  end
         | 
| 185 | 
            +
                  if opts['ignore-if-exists'] && @remotes.exists?(host, port)
         | 
| 186 | 
            +
                    @log.info("#{host}:#{port} already exists, won't add because of --ignore-if-exists")
         | 
| 187 | 
            +
                    return
         | 
| 188 | 
            +
                  end
         | 
| 182 189 | 
             
                  unless opts['skip-ping']
         | 
| 183 190 | 
             
                    res = Http.new(uri: "http://#{host}:#{port}/version", network: opts['network']).get
         | 
| 184 191 | 
             
                    raise "The node #{host}:#{port} is not responding, #{res.code}:#{res.message}" unless res.code == '200'
         | 
    
        data/lib/zold/node/front.rb
    CHANGED
    
    | @@ -55,27 +55,23 @@ module Zold | |
| 55 55 | 
             
                  set :lock, false
         | 
| 56 56 | 
             
                  set :show_exceptions, false
         | 
| 57 57 | 
             
                  set :server, :thin
         | 
| 58 | 
            -
                  set : | 
| 59 | 
            -
                  set : | 
| 60 | 
            -
                  set : | 
| 58 | 
            +
                  set :opts, nil # to be injected at node.rb
         | 
| 59 | 
            +
                  set :log, nil # to be injected at node.rb
         | 
| 60 | 
            +
                  set :trace, nil # to be injected at node.rb
         | 
| 61 61 | 
             
                  set :dump_errors, false # to be injected at node.rb
         | 
| 62 | 
            -
                  set :version, VERSION # to be injected at node.rb
         | 
| 63 62 | 
             
                  set :protocol, PROTOCOL # to be injected at node.rb
         | 
| 64 | 
            -
                  set :ignore_score_weakness, false # to be injected at node.rb
         | 
| 65 | 
            -
                  set :reboot, false # to be injected at node.rb
         | 
| 66 63 | 
             
                  set :nohup_log, false # to be injected at node.rb
         | 
| 67 | 
            -
                  set :home, nil | 
| 64 | 
            +
                  set :home, nil # to be injected at node.rb
         | 
| 68 65 | 
             
                  set :logging, true # to be injected at node.rb
         | 
| 69 | 
            -
                  set :logger, nil | 
| 70 | 
            -
                  set :address, nil | 
| 71 | 
            -
                  set :farm, nil | 
| 72 | 
            -
                  set :metronome, nil | 
| 73 | 
            -
                  set :entrance, nil | 
| 74 | 
            -
                  set : | 
| 75 | 
            -
                  set : | 
| 76 | 
            -
                  set : | 
| 77 | 
            -
                  set : | 
| 78 | 
            -
                  set :node_alias, nil? # to be injected at node.rb
         | 
| 66 | 
            +
                  set :logger, nil # to be injected at node.rb
         | 
| 67 | 
            +
                  set :address, nil # to be injected at node.rb
         | 
| 68 | 
            +
                  set :farm, nil # to be injected at node.rb
         | 
| 69 | 
            +
                  set :metronome, nil # to be injected at node.rb
         | 
| 70 | 
            +
                  set :entrance, nil # to be injected at node.rb
         | 
| 71 | 
            +
                  set :wallets, nil # to be injected at node.rb
         | 
| 72 | 
            +
                  set :remotes, nil # to be injected at node.rb
         | 
| 73 | 
            +
                  set :copies, nil # to be injected at node.rb
         | 
| 74 | 
            +
                  set :node_alias, nil # to be injected at node.rb
         | 
| 79 75 | 
             
                  set :zache, Zache.new
         | 
| 80 76 | 
             
                end
         | 
| 81 77 | 
             
                use Rack::Deflater
         | 
| @@ -84,14 +80,14 @@ module Zold | |
| 84 80 | 
             
                  Thread.current.thread_variable_set(:uri, request.url)
         | 
| 85 81 | 
             
                  Thread.current.thread_variable_set(:ip, request.ip)
         | 
| 86 82 | 
             
                  @start = Time.now
         | 
| 87 | 
            -
                  if !settings.halt.empty? && params[:halt] && params[:halt] == settings.halt
         | 
| 83 | 
            +
                  if !settings.opts['halt-code'].empty? && params[:halt] && params[:halt] == settings.opts['halt-code']
         | 
| 88 84 | 
             
                    settings.log.error('Halt signal received, shutting the front end down...')
         | 
| 89 85 | 
             
                    Front.stop!
         | 
| 90 86 | 
             
                  end
         | 
| 91 87 | 
             
                  check_header(Http::NETWORK_HEADER) do |header|
         | 
| 92 | 
            -
                    if header != settings.network
         | 
| 88 | 
            +
                    if header != settings.opts['network']
         | 
| 93 89 | 
             
                      error(400, "Network name mismatch at #{request.url}, #{request.ip} is in '#{header}', \
         | 
| 94 | 
            -
            while #{settings.address} is in '#{settings.network}'")
         | 
| 90 | 
            +
            while #{settings.address} is in '#{settings.opts['network']}'")
         | 
| 95 91 | 
             
                    end
         | 
| 96 92 | 
             
                  end
         | 
| 97 93 | 
             
                  check_header(Http::PROTOCOL_HEADER) do |header|
         | 
| @@ -100,19 +96,23 @@ while #{settings.address} is in '#{settings.network}'") | |
| 100 96 | 
             
                    end
         | 
| 101 97 | 
             
                  end
         | 
| 102 98 | 
             
                  check_header(Http::SCORE_HEADER) do |header|
         | 
| 103 | 
            -
                    settings. | 
| 104 | 
            -
             | 
| 105 | 
            -
                     | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
                      error(400, ' | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
                       | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 99 | 
            +
                    if settings.opts['standalone']
         | 
| 100 | 
            +
                      settings.log.debug("#{request.url}: we are in standalone mode, won't update remotes")
         | 
| 101 | 
            +
                    else
         | 
| 102 | 
            +
                      s = Score.parse_text(header)
         | 
| 103 | 
            +
                      error(400, 'The score is invalid') unless s.valid?
         | 
| 104 | 
            +
                      error(400, 'The score is weak') if s.strength < Score::STRENGTH && !settings.opts['ignore-score-weakness']
         | 
| 105 | 
            +
                      if settings.address == "#{s.host}:#{s.port}" && !settings.opts['ignore-score-weakness']
         | 
| 106 | 
            +
                        error(400, 'Self-requests are prohibited')
         | 
| 107 | 
            +
                      end
         | 
| 108 | 
            +
                      require_relative '../commands/remote'
         | 
| 109 | 
            +
                      begin
         | 
| 110 | 
            +
                        Remote.new(remotes: settings.remotes, log: settings.log).run(
         | 
| 111 | 
            +
                          ['remote', 'add', s.host, s.port.to_s, "--network=#{settings.opts['network']}", '--ignore-if-exists']
         | 
| 112 | 
            +
                        )
         | 
| 113 | 
            +
                      rescue StandardError => e
         | 
| 114 | 
            +
                        error(400, e.message)
         | 
| 115 | 
            +
                      end
         | 
| 116 116 | 
             
                    end
         | 
| 117 117 | 
             
                  end
         | 
| 118 118 | 
             
                end
         | 
| @@ -121,7 +121,7 @@ while #{settings.address} is in '#{settings.network}'") | |
| 121 121 | 
             
                #  Currently there are no tests at all that would verify the headers.
         | 
| 122 122 | 
             
                after do
         | 
| 123 123 | 
             
                  headers['Cache-Control'] = 'no-cache'
         | 
| 124 | 
            -
                  headers['X-Zold-Version'] = settings.version
         | 
| 124 | 
            +
                  headers['X-Zold-Version'] = settings.opts['expose-version']
         | 
| 125 125 | 
             
                  headers[Http::PROTOCOL_HEADER] = settings.protocol.to_s
         | 
| 126 126 | 
             
                  headers['Access-Control-Allow-Origin'] = '*'
         | 
| 127 127 | 
             
                  headers[Http::SCORE_HEADER] = score.reduced(16).to_s
         | 
| @@ -142,7 +142,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 142 142 |  | 
| 143 143 | 
             
                get '/version' do
         | 
| 144 144 | 
             
                  content_type('text/plain')
         | 
| 145 | 
            -
                  settings.version
         | 
| 145 | 
            +
                  settings.opts['expose-version']
         | 
| 146 146 | 
             
                end
         | 
| 147 147 |  | 
| 148 148 | 
             
                get '/protocol' do
         | 
| @@ -186,9 +186,9 @@ in #{Age.new(@start, limit: 1)}") | |
| 186 186 | 
             
                get '/' do
         | 
| 187 187 | 
             
                  content_type('application/json')
         | 
| 188 188 | 
             
                  JSON.pretty_generate(
         | 
| 189 | 
            -
                    version: settings.version,
         | 
| 189 | 
            +
                    version: settings.opts['expose-version'],
         | 
| 190 190 | 
             
                    alias: settings.node_alias,
         | 
| 191 | 
            -
                    network: settings.network,
         | 
| 191 | 
            +
                    network: settings.opts['network'],
         | 
| 192 192 | 
             
                    protocol: settings.protocol,
         | 
| 193 193 | 
             
                    score: score.to_h,
         | 
| 194 194 | 
             
                    pid: Process.pid,
         | 
| @@ -218,12 +218,12 @@ in #{Age.new(@start, limit: 1)}") | |
| 218 218 | 
             
                end
         | 
| 219 219 |  | 
| 220 220 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})} do
         | 
| 221 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 221 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 222 222 | 
             
                  id = Id.new(params[:id])
         | 
| 223 223 | 
             
                  copy_of(id) do |wallet|
         | 
| 224 224 | 
             
                    content_type('application/json')
         | 
| 225 225 | 
             
                    JSON.pretty_generate(
         | 
| 226 | 
            -
                      version: settings.version,
         | 
| 226 | 
            +
                      version: settings.opts['expose-version'],
         | 
| 227 227 | 
             
                      alias: settings.node_alias,
         | 
| 228 228 | 
             
                      protocol: settings.protocol,
         | 
| 229 229 | 
             
                      id: wallet.id.to_s,
         | 
| @@ -240,12 +240,12 @@ in #{Age.new(@start, limit: 1)}") | |
| 240 240 | 
             
                end
         | 
| 241 241 |  | 
| 242 242 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16}).json} do
         | 
| 243 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 243 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 244 244 | 
             
                  id = Id.new(params[:id])
         | 
| 245 245 | 
             
                  copy_of(id) do |wallet|
         | 
| 246 246 | 
             
                    content_type('application/json')
         | 
| 247 247 | 
             
                    JSON.pretty_generate(
         | 
| 248 | 
            -
                      version: settings.version,
         | 
| 248 | 
            +
                      version: settings.opts['expose-version'],
         | 
| 249 249 | 
             
                      alias: settings.node_alias,
         | 
| 250 250 | 
             
                      protocol: settings.protocol,
         | 
| 251 251 | 
             
                      id: wallet.id.to_s,
         | 
| @@ -261,7 +261,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 261 261 | 
             
                end
         | 
| 262 262 |  | 
| 263 263 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/balance} do
         | 
| 264 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 264 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 265 265 | 
             
                  id = Id.new(params[:id])
         | 
| 266 266 | 
             
                  copy_of(id) do |wallet|
         | 
| 267 267 | 
             
                    content_type 'text/plain'
         | 
| @@ -270,7 +270,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 270 270 | 
             
                end
         | 
| 271 271 |  | 
| 272 272 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/key} do
         | 
| 273 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 273 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 274 274 | 
             
                  id = Id.new(params[:id])
         | 
| 275 275 | 
             
                  copy_of(id) do |wallet|
         | 
| 276 276 | 
             
                    content_type 'text/plain'
         | 
| @@ -279,7 +279,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 279 279 | 
             
                end
         | 
| 280 280 |  | 
| 281 281 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/mtime} do
         | 
| 282 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 282 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 283 283 | 
             
                  id = Id.new(params[:id])
         | 
| 284 284 | 
             
                  copy_of(id) do |wallet|
         | 
| 285 285 | 
             
                    content_type 'text/plain'
         | 
| @@ -288,7 +288,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 288 288 | 
             
                end
         | 
| 289 289 |  | 
| 290 290 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/digest} do
         | 
| 291 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 291 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 292 292 | 
             
                  id = Id.new(params[:id])
         | 
| 293 293 | 
             
                  copy_of(id) do |wallet|
         | 
| 294 294 | 
             
                    content_type 'text/plain'
         | 
| @@ -297,7 +297,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 297 297 | 
             
                end
         | 
| 298 298 |  | 
| 299 299 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})\.txt} do
         | 
| 300 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 300 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 301 301 | 
             
                  id = Id.new(params[:id])
         | 
| 302 302 | 
             
                  copy_of(id) do |wallet|
         | 
| 303 303 | 
             
                    content_type 'text/plain'
         | 
| @@ -321,7 +321,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 321 321 | 
             
                end
         | 
| 322 322 |  | 
| 323 323 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})\.bin} do
         | 
| 324 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 324 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 325 325 | 
             
                  id = Id.new(params[:id])
         | 
| 326 326 | 
             
                  copy_of(id) do |wallet|
         | 
| 327 327 | 
             
                    content_type 'text/plain'
         | 
| @@ -330,7 +330,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 330 330 | 
             
                end
         | 
| 331 331 |  | 
| 332 332 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/copies} do
         | 
| 333 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 333 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 334 334 | 
             
                  id = Id.new(params[:id])
         | 
| 335 335 | 
             
                  copy_of(id) do
         | 
| 336 336 | 
             
                    content_type 'text/plain'
         | 
| @@ -348,7 +348,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 348 348 | 
             
                end
         | 
| 349 349 |  | 
| 350 350 | 
             
                get %r{/wallet/(?<id>[A-Fa-f0-9]{16})/copy/(?<name>[0-9]+)} do
         | 
| 351 | 
            -
                  error(404, 'FETCH is disabled with --disable-fetch') if settings. | 
| 351 | 
            +
                  error(404, 'FETCH is disabled with --disable-fetch') if settings.opts['disable-fetch']
         | 
| 352 352 | 
             
                  id = Id.new(params[:id])
         | 
| 353 353 | 
             
                  name = params[:name]
         | 
| 354 354 | 
             
                  copy_of(id) do
         | 
| @@ -360,7 +360,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 360 360 | 
             
                end
         | 
| 361 361 |  | 
| 362 362 | 
             
                put %r{/wallet/(?<id>[A-Fa-f0-9]{16})/?} do
         | 
| 363 | 
            -
                  error(404, 'PUSH is disabled with --disable-push') if settings. | 
| 363 | 
            +
                  error(404, 'PUSH is disabled with --disable-push') if settings.opts['disable-fetch']
         | 
| 364 364 | 
             
                  request.body.rewind
         | 
| 365 365 | 
             
                  modified = settings.entrance.push(Id.new(params[:id]), request.body.read.to_s)
         | 
| 366 366 | 
             
                  if modified.empty?
         | 
| @@ -368,7 +368,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 368 368 | 
             
                    return
         | 
| 369 369 | 
             
                  end
         | 
| 370 370 | 
             
                  JSON.pretty_generate(
         | 
| 371 | 
            -
                    version: settings.version,
         | 
| 371 | 
            +
                    version: settings.opts['expose-version'],
         | 
| 372 372 | 
             
                    alias: settings.node_alias,
         | 
| 373 373 | 
             
                    score: score.to_h,
         | 
| 374 374 | 
             
                    wallets: total_wallets
         | 
| @@ -378,7 +378,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 378 378 | 
             
                get '/remotes' do
         | 
| 379 379 | 
             
                  content_type('application/json')
         | 
| 380 380 | 
             
                  JSON.pretty_generate(
         | 
| 381 | 
            -
                    version: settings.version,
         | 
| 381 | 
            +
                    version: settings.opts['expose-version'],
         | 
| 382 382 | 
             
                    alias: settings.node_alias,
         | 
| 383 383 | 
             
                    score: score.to_h,
         | 
| 384 384 | 
             
                    all: all_remotes,
         | 
| @@ -450,18 +450,18 @@ in #{Age.new(@start, limit: 1)}") | |
| 450 450 | 
             
                #  takes a lot of time (when the amount of wallets is big, like 40K). However,
         | 
| 451 451 | 
             
                #  we must find a way to count them somehow faster.
         | 
| 452 452 | 
             
                def total_wallets
         | 
| 453 | 
            -
                  return 256 if settings.network == Wallet::MAIN_NETWORK
         | 
| 453 | 
            +
                  return 256 if settings.opts['network'] == Wallet::MAIN_NETWORK
         | 
| 454 454 | 
             
                  settings.wallets.all.count
         | 
| 455 455 | 
             
                end
         | 
| 456 456 |  | 
| 457 457 | 
             
                def all_remotes
         | 
| 458 | 
            -
                  settings.zache.get(:remotes, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 458 | 
            +
                  settings.zache.get(:remotes, lifetime: settings.opts['network'] == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 459 459 | 
             
                    settings.remotes.all
         | 
| 460 460 | 
             
                  end
         | 
| 461 461 | 
             
                end
         | 
| 462 462 |  | 
| 463 463 | 
             
                def processes_count
         | 
| 464 | 
            -
                  settings.zache.get(:processes, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 464 | 
            +
                  settings.zache.get(:processes, lifetime: settings.opts['network'] == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 465 465 | 
             
                    processes.count
         | 
| 466 466 | 
             
                  end
         | 
| 467 467 | 
             
                end
         | 
| @@ -471,7 +471,7 @@ in #{Age.new(@start, limit: 1)}") | |
| 471 471 | 
             
                end
         | 
| 472 472 |  | 
| 473 473 | 
             
                def score
         | 
| 474 | 
            -
                  settings.zache.get(:score, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 474 | 
            +
                  settings.zache.get(:score, lifetime: settings.opts['network'] == Wallet::MAIN_NETWORK ? 60 : 0) do
         | 
| 475 475 | 
             
                    b = settings.farm.best
         | 
| 476 476 | 
             
                    raise 'Score is empty, there is something wrong with the Farm!' if b.empty?
         | 
| 477 477 | 
             
                    b[0]
         | 
    
        data/lib/zold/version.rb
    CHANGED
    
    
    
        data/test/node/fake_node.rb
    CHANGED
    
    | @@ -65,7 +65,7 @@ class FakeNode | |
| 65 65 | 
             
                    uri = "http://localhost:#{port}/"
         | 
| 66 66 | 
             
                    attempt = 0
         | 
| 67 67 | 
             
                    loop do
         | 
| 68 | 
            -
                      ping = Zold::Http.new(uri: uri | 
| 68 | 
            +
                      ping = Zold::Http.new(uri: uri).get
         | 
| 69 69 | 
             
                      break unless ping.code == '599' && node.alive?
         | 
| 70 70 | 
             
                      @log.debug("Waiting for #{uri} (attempt no.#{attempt}): ##{ping.code}...")
         | 
| 71 71 | 
             
                      sleep 0.5
         | 
    
        data/test/node/test_front.rb
    CHANGED
    
    | @@ -265,11 +265,11 @@ class FrontTest < Zold::Test | |
| 265 265 |  | 
| 266 266 | 
             
              def test_headers_are_being_set_correctly
         | 
| 267 267 | 
             
                Time.stub :now, Time.at(0) do
         | 
| 268 | 
            -
                  FakeNode.new(log: test_log).run(['--no-metronome', '--threads=0' | 
| 268 | 
            +
                  FakeNode.new(log: test_log).run(['--expose-version=9.9.9', '--no-metronome', '--threads=0']) do |port|
         | 
| 269 269 | 
             
                    response = Zold::Http.new(uri: URI("http://localhost:#{port}/")).get
         | 
| 270 270 | 
             
                    assert_equal('no-cache', response.header['Cache-Control'])
         | 
| 271 271 | 
             
                    assert_equal('close', response.header['Connection'])
         | 
| 272 | 
            -
                    assert_equal( | 
| 272 | 
            +
                    assert_equal('9.9.9', response.header['X-Zold-Version'])
         | 
| 273 273 | 
             
                    assert_equal(app.settings.protocol.to_s, response.header[Zold::Http::PROTOCOL_HEADER])
         | 
| 274 274 | 
             
                    assert_equal('*', response.header['Access-Control-Allow-Origin'])
         | 
| 275 275 | 
             
                    assert(response.header['X-Zold-Milliseconds'])
         | 
    
        data/test/test_zold.rb
    CHANGED
    
    | @@ -34,8 +34,7 @@ require_relative '../lib/zold/age' | |
| 34 34 | 
             
            # License:: MIT
         | 
| 35 35 | 
             
            class TestZold < Zold::Test
         | 
| 36 36 | 
             
              Dir.new('fixtures/scripts').select { |f| f =~ /\.sh$/ && !f.start_with?('_') }.each do |f|
         | 
| 37 | 
            -
                # | 
| 38 | 
            -
                define_method("test_script_#{f.gsub(/[^a-z]/, '_')}") do
         | 
| 37 | 
            +
                define_method("test_#{f.gsub(/\.sh$/, '').gsub(/[^a-z]/, '_')}") do
         | 
| 39 38 | 
             
                  start = Time.now
         | 
| 40 39 | 
             
                  test_log.debug("\n\n#{f} running...")
         | 
| 41 40 | 
             
                  Dir.mktmpdir do |dir|
         | 
    
        data/zold.gemspec
    CHANGED
    
    | @@ -75,7 +75,7 @@ and suggests a different architecture for digital wallet maintenance.' | |
| 75 75 | 
             
              s.add_runtime_dependency 'threads', '0.3.0'
         | 
| 76 76 | 
             
              s.add_runtime_dependency 'usagewatch_ext', '0.2.1'
         | 
| 77 77 | 
             
              s.add_runtime_dependency 'xcop', '0.6'
         | 
| 78 | 
            -
              s.add_runtime_dependency 'zache', '0.3. | 
| 78 | 
            +
              s.add_runtime_dependency 'zache', '0.3.1'
         | 
| 79 79 | 
             
              s.add_runtime_dependency 'zold-score', '0.2.0'
         | 
| 80 80 | 
             
              s.add_development_dependency 'codecov', '0.1.13'
         | 
| 81 81 | 
             
              s.add_development_dependency 'minitest', '5.11.3'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: zold
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.16. | 
| 4 | 
            +
              version: 0.16.19
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Yegor Bugayenko
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-11- | 
| 11 | 
            +
            date: 2018-11-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: backtrace
         | 
| @@ -310,14 +310,14 @@ dependencies: | |
| 310 310 | 
             
                requirements:
         | 
| 311 311 | 
             
                - - '='
         | 
| 312 312 | 
             
                  - !ruby/object:Gem::Version
         | 
| 313 | 
            -
                    version: 0.3. | 
| 313 | 
            +
                    version: 0.3.1
         | 
| 314 314 | 
             
              type: :runtime
         | 
| 315 315 | 
             
              prerelease: false
         | 
| 316 316 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 317 317 | 
             
                requirements:
         | 
| 318 318 | 
             
                - - '='
         | 
| 319 319 | 
             
                  - !ruby/object:Gem::Version
         | 
| 320 | 
            -
                    version: 0.3. | 
| 320 | 
            +
                    version: 0.3.1
         | 
| 321 321 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 322 322 | 
             
              name: zold-score
         | 
| 323 323 | 
             
              requirement: !ruby/object:Gem::Requirement
         |