Skip to content

Commit

Permalink
Clean up of address generation
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-dtk committed May 15, 2020
1 parent b5b5ebc commit c8dbce9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
20 changes: 10 additions & 10 deletions docker-compose.yaml → common/ruby/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ version: '3'
services:
generate-raw-addresses:
build:
context: ./common/ruby
context: ./
dockerfile: Dockerfile-dev
command: bash -c "/bin-mount/generate-raw-addresses-if-needed 53 /addresses/raw-addresses.txt /addresses/addresses.yaml"
volumes:
- ./bin/bash:/bin-mount
- ./build/generated-addresses:/addresses:rw
- ./build/state:/state:rw
- ../../bin/bash:/bin-mount
- ../../build/generated-addresses:/addresses:rw
- ../../build/state:/state:rw

setup-network:
build:
context: ./common/ruby
context: ./
dockerfile: Dockerfile-dev
command: bash -c "sleep infinity"
# command: bash -c "/usr/app/bin/setup-network.rb && touch /state/configs-generated"
Expand All @@ -38,8 +38,8 @@ services:
- BASE_CONFIG_DIR=/config-build
- NEMESIS_DIR=/nemesis
volumes:
- ./common/ruby:/usr/app
- ./build/generated-addresses:/addresses
- ./build/catapult-config:/config-build
- ./build/nemesis:/nemesis:rw
- ./build/state:/state:rw
- ./:/usr/app
- ../../build/generated-addresses:/addresses
- ../../build/catapult-config:/config-build
- ../../build/nemesis:/nemesis:rw
- ../../build/state:/state:rw
29 changes: 19 additions & 10 deletions common/ruby/lib/catapult/bootstrap/addresses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,29 @@ class Addresses
ParseKey.nemesis_signer_private_key => 1
}

def initialize(input_file_path, address_total)
@input_file_path = input_file_path
@address_total = address_total
def initialize(address_total, raw_addresses_path: nil )
@address_total = address_total
@raw_addresses_path = raw_addresses_path
end

def self.parse(input_file_path, address_total, output_form: nil)
new(input_file_path, address_total).parse(output_form: output_form)

def self.generate_and_parse(address_total)
new(address_total).generate_and_parse
end

# TODO: these can be deprecated
def self.parse(raw_addresses_path, address_total, output_form: nil)
new(address_total, raw_addresses_path: raw_addresses_path).parse(output_form: output_form)
end
def parse(output_form: nil)
Parse.parse(self.raw_address_info, self.section_sizes, break_into_sections: true, output_form: output_form)
Parse.parse(raw_address_info_from_file, self.section_sizes, break_into_sections: true, output_form: output_form)
end

protected

attr_reader :input_file_path, :address_total
attr_reader :address_total

def raw_address_info
@raw_address_info ||= ::File.open(self.input_file_path).read
def raw_addresses_path
@raw_addresses_path || fail("@raw_addresses_path is nil")
end

def section_sizes
Expand All @@ -56,6 +61,10 @@ def num_harvesting_keys
end

private

def raw_address_info_from_file
::File.open(self.raw_addresses_path).read
end

def ret_section_sizes
# Rules are that nemesis_addresses_harvesting_vrf has same size as nemesis_addresses_harvesting and
Expand Down

0 comments on commit c8dbce9

Please sign in to comment.