class Zold::List

LIST command

Public Class Methods

new(wallets:, copies:, log: Log::NULL) click to toggle source
# File lib/zold/commands/list.rb, line 38
def initialize(wallets:, copies:, log: Log::NULL)
  @wallets = wallets
  @copies = copies
  @log = log
end

Public Instance Methods

run(_ = []) click to toggle source
# File lib/zold/commands/list.rb, line 44
def run(_ = [])
  total = 0
  txns = 0
  size = 0
  balance = Amount::ZERO
  @wallets.all.sort.each do |id|
    total += 1
    cps = Copies.new(File.join(@copies, id))
    @wallets.acq(id) do |wallet|
      msg = "#{wallet.mnemo} #{cps.all.count}c"
      msg += " (net:#{wallet.network})" if wallet.network != Wallet::MAINET
      txns += wallet.txns.count
      balance += wallet.balance
      size += wallet.size
      @log.info(msg)
    end
  end
  @log.info("#{total} wallets, #{txns} transactions, #{Size.new(size)}, #{balance} in total")
end