Sha256: 4faeaa9c828569bbeb66eaa0a5800de745b955c423d6eb9da802979813fc61fd

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

require 'iniparse'

module Tapyrus
  module Node
    class Configuration

      attr_reader :conf

      def initialize(opts = {})
        # TODO apply configuration file.
        opts[:network] = :mainnet unless opts[:network]
        opts[:relay] = false unless opts[:relay]
        Tapyrus.chain_params = opts[:network]

        begin
          ini_file = IniParse.parse(File.read("#{Tapyrus.base_dir}/tapyrusrb.conf"))
          @conf = Hash[ ini_file.to_h['__anonymous__'].map{|k,v| [k.to_sym, v] } ]
        rescue => e
          @conf = {}
        end
        @conf.merge!(opts)
      end

      def host
        'localhost'
      end

      def port
        Tapyrus.chain_params.default_port - 1
      end

      def server_url
        "http://#{host}:#{port}"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tapyrus-0.1.0 lib/tapyrus/node/configuration.rb