onchain 1.0.14 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/onchain/block_chain.rb +11 -2
- data/lib/onchain/providers/blockr_api.rb +11 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35eb379f39377e1760d16155b6ccfdc8f005acdb
|
4
|
+
data.tar.gz: 7dd86a609e7cb720c91f6fd782b66f4a21586e14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d3062c800f92af529b6fed50893c063b26dbd9b87b0ff4a83bbea39ae0d3ed9e10faf48a5c8f0cb20fb79664d67c49d5b7916ac700d9db2cc223f8690bd1a64
|
7
|
+
data.tar.gz: 1f11bf162a472f1785b049de8d037f149d011deeab39c6f39443bd33b1f34c8e47ce2e5d90d12bbd9a6c73852888c504110c8cdf3e50822324e19e883f45f009
|
data/lib/onchain/block_chain.rb
CHANGED
@@ -22,7 +22,7 @@ class OnChain::BlockChain
|
|
22
22
|
|
23
23
|
def method_missing (method_name, *args, &block)
|
24
24
|
|
25
|
-
get_available_suppliers.each do |supplier|
|
25
|
+
get_available_suppliers(method_name).each do |supplier|
|
26
26
|
|
27
27
|
real_method = "#{supplier.to_s}_#{method_name}"
|
28
28
|
begin
|
@@ -48,10 +48,19 @@ class OnChain::BlockChain
|
|
48
48
|
return (get_balance(address).to_f * 100000000).to_i
|
49
49
|
end
|
50
50
|
|
51
|
-
def get_available_suppliers
|
51
|
+
def get_available_suppliers(method_name)
|
52
52
|
available = []
|
53
53
|
ALL_SUPPLIERS.each do |supplier|
|
54
54
|
if cache_read(supplier.to_s) == nil
|
55
|
+
|
56
|
+
if supplier == :blockinfo and method_name == 'send_tx'
|
57
|
+
next
|
58
|
+
end
|
59
|
+
|
60
|
+
if supplier == :blockinfo and method_name == 'get_transactions'
|
61
|
+
next
|
62
|
+
end
|
63
|
+
|
55
64
|
available << supplier
|
56
65
|
end
|
57
66
|
end
|
@@ -1,5 +1,15 @@
|
|
1
1
|
class OnChain::BlockChain
|
2
2
|
class << self
|
3
|
+
|
4
|
+
def blockr_send_tx(tx_hex)
|
5
|
+
uri = URI.parse("http://btc.blockr.io/api/v1/tx/push")
|
6
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
7
|
+
|
8
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
9
|
+
request.body = '{"hex":"' + tx_hex + '"}'
|
10
|
+
response = http.request(request)
|
11
|
+
return response
|
12
|
+
end
|
3
13
|
|
4
14
|
def blockr_get_balance(address)
|
5
15
|
if cache_read(address) == nil
|
@@ -58,7 +68,7 @@ class OnChain::BlockChain
|
|
58
68
|
json = fetch_response(URI::encode(base))
|
59
69
|
|
60
70
|
json['data'].each do |data|
|
61
|
-
bal = data['balance']
|
71
|
+
bal = data['balance'].to_f
|
62
72
|
addr = data['address']
|
63
73
|
cache_write(addr, bal, BALANCE_CACHE_FOR)
|
64
74
|
end
|