Class: Avalon::Blockchain
- Inherits:
-
Object
- Object
- Avalon::Blockchain
- Defined in:
- lib/avalon/blockchain.rb
Overview
Block contains details about block found by the pool
Class Method Summary collapse
-
.conn ⇒ Object
Establish Faraday connection on first call.
- .get(path) ⇒ Object
- .rawblock(block_hash) ⇒ Object
Class Method Details
.conn ⇒ Object
Establish Faraday connection on first call
13 14 15 16 17 18 |
# File 'lib/avalon/blockchain.rb', line 13 def conn @conn ||= Faraday.new(:url => 'http://blockchain.info') do |faraday| # faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end |
.get(path) ⇒ Object
24 25 26 27 |
# File 'lib/avalon/blockchain.rb', line 24 def get path reply = conn.get "#{path}?format=json" JSON.parse(reply.body) if reply.success? end |
.rawblock(block_hash) ⇒ Object
20 21 22 |
# File 'lib/avalon/blockchain.rb', line 20 def rawblock block_hash get "rawblock/#{block_hash}" end |