Class: Bitcoin::Node::Configuration
- Defined in:
- lib/bitcoin/node/configuration.rb
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(opts = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #port ⇒ Object
- #server_url ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bitcoin/node/configuration.rb', line 9 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 |
Instance Attribute Details
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
7 8 9 |
# File 'lib/bitcoin/node/configuration.rb', line 7 def conf @conf end |
Instance Method Details
#host ⇒ Object
24 25 26 |
# File 'lib/bitcoin/node/configuration.rb', line 24 def host 'localhost' end |
#port ⇒ Object
28 29 30 |
# File 'lib/bitcoin/node/configuration.rb', line 28 def port Bitcoin.chain_params.default_port - 1 end |
#server_url ⇒ Object
32 33 34 |
# File 'lib/bitcoin/node/configuration.rb', line 32 def server_url "http://#{host}:#{port}" end |