Class: Zold::Upgrades

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/upgrades.rb

Overview

Class to manage data upgrades (when zold itself upgrades).

Instance Method Summary collapse

Constructor Details

#initialize(version, directory, opts, log: Log::VERBOSE) ⇒ Upgrades

Returns a new instance of Upgrades.



28
29
30
31
32
33
34
# File 'lib/zold/upgrades.rb', line 28

def initialize(version, directory, opts, log: Log::VERBOSE)
  raise 'network can\'t be nil' if opts[:network].nil?
  @version = version
  @directory = directory
  @log = log
  @opts = opts
end

Instance Method Details

#runObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/zold/upgrades.rb', line 36

def run
  Dir.glob("#{@directory}/*.rb").select { |f| f =~ /^(\d+)\.rb$/ }.sort.each do |script|
    @version.apply(script)
  end
  command = @opts[:command]
  require_relative '../../upgrades/delete_banned_wallets'
  DeleteBannedWallets.new(Dir.pwd, @log).exec
  require_relative '../../upgrades/2'
  UpgradeTo2.new(Dir.pwd, @log).exec
  require_relative '../../upgrades/protocol_up'
  ProtocolUp.new(Dir.pwd, @log).exec
  require_relative '../../upgrades/rename_foreign_wallets'
  RenameForeignWallets.new(Dir.pwd, @opts[:network], @log).exec
  return unless command == 'node'
  require_relative '../../upgrades/move_wallets_into_tree'
  MoveWalletsIntoTree.new(Dir.pwd, @log).exec
end