Sha256: 3c3c00c34466257fa016b80016aaff3eddef9136b4e4ea416879a44bf69de730

Contents?: true

Size: 798 Bytes

Versions: 18

Compression:

Stored size: 798 Bytes

Contents

require 'iniparse'

module Bitcoin
  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]
        Bitcoin.chain_params = opts[:network]

        begin
          ini_file = IniParse.parse(File.read("#{Bitcoin.base_dir}/bitcoinrb.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
        Bitcoin.chain_params.default_port - 1
      end

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

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bitcoinrb-0.5.0 lib/bitcoin/node/configuration.rb
bitcoinrb-0.4.0 lib/bitcoin/node/configuration.rb
bitcoinrb-0.3.2 lib/bitcoin/node/configuration.rb
bitcoinrb-0.3.1 lib/bitcoin/node/configuration.rb
bitcoinrb-0.3.0 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.9 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.8 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.7 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.6 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.5 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.4 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.2 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.1 lib/bitcoin/node/configuration.rb
bitcoinrb-0.2.0 lib/bitcoin/node/configuration.rb
bitcoinrb-0.1.9 lib/bitcoin/node/configuration.rb
bitcoinrb-0.1.8 lib/bitcoin/node/configuration.rb
bitcoinrb-0.1.7 lib/bitcoin/node/configuration.rb
bitcoinrb-0.1.6 lib/bitcoin/node/configuration.rb