radiator 0.4.5 → 0.4.6pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/radiator/ssc/base_steem_smart_contract_rpc.rb +52 -10
- data/lib/radiator/ssc/blockchain.rb +10 -0
- data/lib/radiator/ssc/contracts.rb +17 -0
- data/lib/radiator/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f3d29e8d5a72406abdbe9a8a483a37bae11500ac161f6ef1d572590dfe21b44
|
4
|
+
data.tar.gz: 43f28b9697b5b183288e47eace0d99ce082b4bc0d1758752b91a8d5aba623201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 646108fed41039183164d59e89725c8df0845a94201b634de14b05d109a4e4b9b824ef4431e8ffa37a7b9ae64b3cc38696e104b53b5e6423eafeee41710b78e3
|
7
|
+
data.tar.gz: 4612d9495d2a77ee15660be224eea74082a94d6d29f1e7f5fe7d63bd8d03300ba623c7f7710d5fcd00f9cadc63915263f122b4a90885258e8b0f90d536ae9e98
|
data/README.md
CHANGED
@@ -13,9 +13,9 @@ Radiator is an API Client for interaction with the STEEM network using Ruby.
|
|
13
13
|
#### Changes in v0.4.5
|
14
14
|
|
15
15
|
* Added support to query and stream a Steem Smart Contract backed side-chains like Steem Engine.
|
16
|
-
* [Blockchain](https://www.rubydoc.info/gems/radiator/
|
17
|
-
* [Stream](https://www.rubydoc.info/gems/radiator/
|
18
|
-
* [Contracts](https://www.rubydoc.info/gems/radiator/
|
16
|
+
* [Blockchain](https://www.rubydoc.info/gems/radiator/0.4.5/Radiator/SSC/Blockchain.html)
|
17
|
+
* [Stream](https://www.rubydoc.info/gems/radiator/0.4.5/Radiator/SSC/Stream.html)
|
18
|
+
* [Contracts](https://www.rubydoc.info/gems/radiator/0.4.5/Radiator/SSC/Contracts.html)
|
19
19
|
|
20
20
|
#### Changes in v0.4.0
|
21
21
|
|
@@ -629,7 +629,7 @@ https://github.com/inertia186/radiator/issues/12
|
|
629
629
|
---
|
630
630
|
|
631
631
|
<center>
|
632
|
-
<img src="http://www.steemimg.com/images/2016/08/19/RadiatorCoolingFan-54in-Webfdcb1.png" />
|
632
|
+
<img src="https://steemitimages.com/0x0/http://www.steemimg.com/images/2016/08/19/RadiatorCoolingFan-54in-Webfdcb1.png" />
|
633
633
|
</center>
|
634
634
|
|
635
635
|
See my previous Ruby How To posts in: [#radiator](https://steemit.com/created/radiator) [#ruby](https://steemit.com/created/ruby)
|
@@ -7,6 +7,8 @@ module Radiator
|
|
7
7
|
'User-Agent' => Radiator::AGENT_ID
|
8
8
|
}
|
9
9
|
|
10
|
+
MAX_BACKOFF = 60.0
|
11
|
+
|
10
12
|
def initialize(options = {})
|
11
13
|
@root_url = options[:root_url] || 'https://api.steem-engine.com/rpc'
|
12
14
|
|
@@ -28,6 +30,12 @@ module Radiator
|
|
28
30
|
true
|
29
31
|
end
|
30
32
|
|
33
|
+
@persist = if options[:persist].nil?
|
34
|
+
true
|
35
|
+
else
|
36
|
+
options[:persist]
|
37
|
+
end
|
38
|
+
|
31
39
|
if defined? Net::HTTP::Persistent::DEFAULT_POOL_SIZE
|
32
40
|
@pool_size = options[:pool_size] || Net::HTTP::Persistent::DEFAULT_POOL_SIZE
|
33
41
|
end
|
@@ -61,18 +69,24 @@ module Radiator
|
|
61
69
|
end
|
62
70
|
|
63
71
|
def http
|
64
|
-
@http ||= if
|
65
|
-
Net::HTTP::Persistent
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
72
|
+
@http ||= if persist?
|
73
|
+
if defined? Net::HTTP::Persistent::DEFAULT_POOL_SIZE
|
74
|
+
Net::HTTP::Persistent.new(name: http_id, pool_size: @pool_size).tap do |http|
|
75
|
+
http.keep_alive = 30
|
76
|
+
http.idle_timeout = 10
|
77
|
+
http.max_requests = @max_requests
|
78
|
+
http.retry_change_requests = true
|
79
|
+
http.reuse_ssl_sessions = @reuse_ssl_sessions
|
80
|
+
end
|
81
|
+
else
|
82
|
+
# net-http-persistent < 3.0
|
83
|
+
Net::HTTP::Persistent.new(http_id) do |http|
|
84
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
85
|
+
http.use_ssl = uri.scheme == 'https'
|
86
|
+
end
|
71
87
|
end
|
72
88
|
else
|
73
|
-
|
74
|
-
Net::HTTP::Persistent.new(http_id) do |http|
|
75
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
89
|
+
Net::HTTP.new(uri.host, uri.port).tap do |http|
|
76
90
|
http.use_ssl = uri.scheme == 'https'
|
77
91
|
end
|
78
92
|
end
|
@@ -84,8 +98,27 @@ module Radiator
|
|
84
98
|
|
85
99
|
def request(options)
|
86
100
|
request = post_request
|
101
|
+
skip_health_check = options.delete(:skip_health_check)
|
87
102
|
request.body = JSON[options.merge(jsonrpc: '2.0', id: rpc_id)]
|
88
103
|
|
104
|
+
unless skip_health_check
|
105
|
+
unless healthy?
|
106
|
+
@backoff ||= 0.1
|
107
|
+
|
108
|
+
backoff = @backoff
|
109
|
+
|
110
|
+
if !!backoff
|
111
|
+
raise "Too many failures on #{url}" if backoff >= MAX_BACKOFF
|
112
|
+
|
113
|
+
backoff *= backoff
|
114
|
+
@backoff = backoff
|
115
|
+
sleep backoff
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
@backoff = nil
|
120
|
+
end
|
121
|
+
|
89
122
|
response = case http
|
90
123
|
when Net::HTTP::Persistent then http.request(uri, request)
|
91
124
|
when Net::HTTP then http.request(request)
|
@@ -100,6 +133,15 @@ module Radiator
|
|
100
133
|
|
101
134
|
response.result
|
102
135
|
end
|
136
|
+
|
137
|
+
def healthy?
|
138
|
+
warn("Health check not defined for: #{uri}")
|
139
|
+
true
|
140
|
+
end
|
141
|
+
|
142
|
+
def persist?
|
143
|
+
!!@persist
|
144
|
+
end
|
103
145
|
end
|
104
146
|
end
|
105
147
|
end
|
@@ -42,6 +42,16 @@ module Radiator
|
|
42
42
|
def transaction_info(trx_id)
|
43
43
|
request(method: 'getTransactionInfo', params: {txid: trx_id})
|
44
44
|
end
|
45
|
+
protected
|
46
|
+
def healthy?
|
47
|
+
begin
|
48
|
+
request(method: 'getBlockInfo', params: {blockNumber: -1}, skip_health_check: true).nil?
|
49
|
+
rescue => e
|
50
|
+
warn("Health check for #{uri.inspect} failed: #{e.inspect}")
|
51
|
+
|
52
|
+
!!shutdown
|
53
|
+
end
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
47
57
|
end
|
@@ -66,6 +66,23 @@ module Radiator
|
|
66
66
|
def find(options = {})
|
67
67
|
request(method: 'find', params: options)
|
68
68
|
end
|
69
|
+
protected
|
70
|
+
def healthy?
|
71
|
+
begin
|
72
|
+
request(method: 'find', params: {
|
73
|
+
contract: 'tokens',
|
74
|
+
table: 'transfers',
|
75
|
+
query: {
|
76
|
+
symbol: ''
|
77
|
+
},
|
78
|
+
limit: 0
|
79
|
+
}, skip_health_check: true).nil?
|
80
|
+
rescue => e
|
81
|
+
warn("Health check for #{uri.inspect} failed: #{e.inspect}")
|
82
|
+
|
83
|
+
!!shutdown
|
84
|
+
end
|
85
|
+
end
|
69
86
|
end
|
70
87
|
end
|
71
88
|
end
|
data/lib/radiator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -446,9 +446,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
446
446
|
version: '0'
|
447
447
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
448
448
|
requirements:
|
449
|
-
- - "
|
449
|
+
- - ">"
|
450
450
|
- !ruby/object:Gem::Version
|
451
|
-
version:
|
451
|
+
version: 1.3.1
|
452
452
|
requirements: []
|
453
453
|
rubyforge_project:
|
454
454
|
rubygems_version: 2.7.7
|