bin/zold-stress in zold-stress-0.5.1 vs bin/zold-stress in zold-stress-0.5.2
- old
+ new
@@ -42,12 +42,12 @@
Thread.current.name = 'main'
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
-log = Zold::Log::Regular.new
-vlog = Zold::Log::Quiet.new
+log = Zold::Log::REGULAR
+vlog = Zold::Log::ERRORS
begin
opts = Slop.parse(ARGV, strict: false, suppress_errors: true) do |o|
o.banner = "Usage: zold-stress [options]
Available options:"
@@ -72,26 +72,23 @@
default: File.expand_path('~/.ssh/id_rsa')
o.string '--home',
"Home directory (default: #{Dir.pwd})",
default: Dir.pwd
o.string '--network',
- "The name of the network we work in (default: #{Zold::Wallet::MAIN_NETWORK}",
+ "The name of the network we work in (default: #{Zold::Wallet::MAINET}",
required: true,
- default: Zold::Wallet::MAIN_NETWORK
+ default: Zold::Wallet::MAINET
o.bool '-h', '--help', 'Show these instructions'
o.on '--verbose', 'Enable extra logging information' do
- log = Zold::Log::Verbose.new
- vlog = Zold::Log::Regular.new
+ log = Zold::Log::VERBOSE
+ vlog = Zold::Log::REGULAR
end
o.on '--no-colors', 'Disable colors in the ouput' do
Rainbow.enabled = false
end
end
- log = Zold::Log::Sync.new(log)
- vlog = Zold::Log::Sync.new(vlog)
-
if opts.help?
log.info(opts.to_s)
exit
end
@@ -110,11 +107,11 @@
remotes.defaults
log.info("The list of remotes has got default nodes, there are #{remotes.all.count} total")
end
copies = File.join(zoldata, 'copies')
- stats = Zold::Stress::Stats.new
+ stats = Zold::Stress::Stats.new(log: vlog)
summary = Zold::Stress::Summary.new(stats, opts['batch'])
air = Zold::Stress::Air.new
round = Zold::Stress::Round.new(
pvt: Zold::Key.new(file: opts['private-key']),
wallets: wallets, remotes: remotes, copies: copies,
@@ -135,20 +132,24 @@
opts['rounds'].times do |r|
round.send
round.pull
round.match
log.info(summary)
- Zold::List.new(wallets: wallets, log: log).run(['list'] + opts.arguments) if (r % 10).zero?
+ round.list if (r % 10).zero?
end
s = Time.now
loop do
break if Time.now > s + opts['wait']
break if air.fetch.empty?
round.pull
round.match
log.info(summary)
end
+ round.list
unless air.fetch.empty?
+ air.fetch.each do |p|
+ log.info(" #{p[:source]} -> #{p[:target]} #{p[:amount]} #{Zold::Age.new(p[:pushed])}")
+ end
raise "#{air.fetch.count} payments out of #{stats.total('paid')} are still somewhere, we lost them :("
end
log.info("Successfully sent and received #{Rainbow(stats.total('arrived')).green} transactions \
in #{Zold::Age.new(start)}")
rescue StandardError => ex