Module: Blockchain
- Defined in:
- lib/block.rb,
lib/address.rb,
lib/realtime.rb,
lib/blockchain.rb,
lib/transaction.rb
Defined Under Namespace
Classes: Address, Block, Transaction
Constant Summary
collapse
- ROOT =
'https://blockchain.info'
Class Method Summary
collapse
Class Method Details
.avg_tx_number ⇒ Object
50
51
52
|
# File 'lib/realtime.rb', line 50
def self.avg_tx_number
self.q('avgtxnumber').to_i
end
|
.avg_tx_size ⇒ Object
34
35
36
|
# File 'lib/realtime.rb', line 34
def self.avg_tx_size
self.q('avgtxsize').to_i
end
|
.avg_tx_value ⇒ Object
38
39
40
|
# File 'lib/realtime.rb', line 38
def self.avg_tx_value
self.q('avgtxvalue').to_i
end
|
.bc_per_block ⇒ Object
14
15
16
|
# File 'lib/realtime.rb', line 14
def self.bc_per_block
Btc.new(self.q('bcperblock'))
end
|
.block_count ⇒ Object
6
7
8
|
# File 'lib/realtime.rb', line 6
def self.block_count
self.q('getblockcount').to_i
end
|
.difficulty ⇒ Object
2
3
4
|
# File 'lib/realtime.rb', line 2
def self.difficulty
BigDecimal.new(self.q('getdifficulty'))
end
|
.eta ⇒ Object
46
47
48
|
# File 'lib/realtime.rb', line 46
def self.eta
BigDecimal.new(self.q('eta'))
end
|
.get(path) ⇒ Object
4
5
6
7
|
# File 'lib/blockchain.rb', line 4
def self.get(path)
response = open("#{ROOT}/#{path}")
response.read if response.status.first == '200'
end
|
.hashes_to_win ⇒ Object
26
27
28
|
# File 'lib/realtime.rb', line 26
def self.hashes_to_win
self.q('hashestowin').to_i
end
|
.interval ⇒ Object
42
43
44
|
# File 'lib/realtime.rb', line 42
def self.interval
BigDecimal.new(self.q('interval'))
end
|
.latest_hash ⇒ Object
10
11
12
|
# File 'lib/realtime.rb', line 10
def self.latest_hash
self.q('latesthash')
end
|
.next_retarget ⇒ Object
30
31
32
|
# File 'lib/realtime.rb', line 30
def self.next_retarget
self.q('nextretarget').to_i
end
|
.probability ⇒ Object
22
23
24
|
# File 'lib/realtime.rb', line 22
def self.probability
BigDecimal.new(self.q('probability'))
end
|
.q(path) ⇒ Object
9
10
11
|
# File 'lib/blockchain.rb', line 9
def self.q(path)
self.get("q/#{path}")
end
|
.rawaddr(address) ⇒ Object
21
22
23
|
# File 'lib/blockchain.rb', line 21
def self.rawaddr(address)
JSON.parse(self.get("rawaddr/#{address}"))
end
|
.rawblock(block) ⇒ Object
13
14
15
|
# File 'lib/blockchain.rb', line 13
def self.rawblock(block)
JSON.parse(self.get("rawblock/#{block}"))
end
|
.rawtx(tx) ⇒ Object
17
18
19
|
# File 'lib/blockchain.rb', line 17
def self.rawtx(tx)
JSON.parse(self.get("rawtx/#{tx}"))
end
|
.total ⇒ Object
18
19
20
|
# File 'lib/realtime.rb', line 18
def self.total
Btc.new(self.q('totalbc'))
end
|