radiator 0.4.0pre3 → 0.4.0pre4
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/.travis.yml +3 -1
- data/Gemfile.lock +1 -1
- data/README.md +54 -0
- data/Rakefile +13 -7
- data/lib/radiator/api.rb +17 -0
- data/lib/radiator/error_parser.rb +36 -14
- data/lib/radiator/transaction.rb +2 -1
- data/lib/radiator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fa87cf414d03f44944ae568a7c96b6c7e268d7c
|
4
|
+
data.tar.gz: 14b86e6768d73cc4842497c8b91547e6cd2add46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 577386edefce45ef60a51476db9b1f76a44a096ac149cdb61fc992af391420a2c35a40fe797921fb9ddc1a6765895e9eff5d636ad378555d0f550e058dd608c9
|
7
|
+
data.tar.gz: 40432819def16218dbc7fa51099791138c4afb1282e7e6c5eb066cee5b0bf4d16245f2e411d4aa5b3de8be73e4a2dedf35343c606d0b3642eb633a566310d0b6
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,60 @@
|
|
10
10
|
|
11
11
|
Radiator is an API Client for interaction with the STEEM network using Ruby.
|
12
12
|
|
13
|
+
#### Changes in v0.4.0
|
14
|
+
|
15
|
+
* Gem updates
|
16
|
+
* AppBase Support
|
17
|
+
* Defaulting to `condenser_api.*` in `Radiator::Api` (see below)
|
18
|
+
* Handle/recover from new `AppBase` errors.
|
19
|
+
* `Radiator::Stream` now detects if it's stalled and takes action if it has to wait too long for a new block.
|
20
|
+
1. Exponential back-off for stalls so that the node doesn't get slammed.
|
21
|
+
2. Short delays (3 times block production) only result in a warning.
|
22
|
+
3. Long delays (6 times block production) may try to switch to an alternate node.
|
23
|
+
* Fixed internal logging bug that would open too many files.
|
24
|
+
* This fix also mitigates issues like `SSL Verify` problems (similar to [#12](https://github.com/inertia186/radiator/issues/12))
|
25
|
+
* Dropped GOLOS support.
|
26
|
+
|
27
|
+
**Appbase is now supported.**
|
28
|
+
|
29
|
+
If you were already using `Radiator::Api` then there is nothing to change. But if you made use of other API classes, like `Radiator::FollowApi`, then the method signatures have changed.
|
30
|
+
|
31
|
+
**Pre-AppBase:**
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
api = Radiator::FollowApi.new
|
35
|
+
|
36
|
+
api.get_followers('inertia', 0, 'blog', 10)
|
37
|
+
```
|
38
|
+
|
39
|
+
**New Signature:**
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
api = Radiator::FollowApi.new
|
43
|
+
|
44
|
+
api.get_followers(account: 'inertia', start: 0, type: 'blog', limit: 10)
|
45
|
+
```
|
46
|
+
|
47
|
+
*-- or --*
|
48
|
+
|
49
|
+
**Switch to Condenser API:**
|
50
|
+
|
51
|
+
The other strategy for using this version of Radiator is to just switch away from classes like `Radiator::FollowApi` over to `Radiator::Api` (also known as `Radiator::CondenserApi`) instead. Then you don't have to update individual method calls.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
api = Radiator::Api.new
|
55
|
+
|
56
|
+
api.get_followers('inertia', 0, 'blog', 10)
|
57
|
+
```
|
58
|
+
|
59
|
+
**Note about GOLOS**
|
60
|
+
|
61
|
+
GOLOS is no longer supported in Radiator. If you want to continue to use GOLOS, you'll need to branch from v0.3.15 (pre-appbase) and add WebSockets support because GOLOS completely dropped JSON-RPC over HTTP clients support for some reason
|
62
|
+
|
63
|
+
Radiator has never and will never use WebSockets due to its server scalability requirements.
|
64
|
+
|
65
|
+
From a client perspective, WebSockets is *great*. **I have nothing against WebSockets.** So I might get around to it at some point, but GOLOS won't be part of Radiator anymore mainly because GOLOS has no plans to implement AppBase.
|
66
|
+
|
13
67
|
#### Changes in v0.3.0
|
14
68
|
|
15
69
|
* Gem updates
|
data/Rakefile
CHANGED
@@ -34,7 +34,9 @@ task :test_live_broadcast, [:account, :wif, :chain] do |t, args|
|
|
34
34
|
account_name = args[:account] || 'social'
|
35
35
|
posting_wif = args[:wif] || '5JrvPrQeBBvCRdjv29iDvkwn3EQYZ9jqfAHzrCyUvfbEbRkrYFC'
|
36
36
|
chain = args[:chain] || 'steem'
|
37
|
-
|
37
|
+
# url = 'https://testnet.steemitdev.com/' # use testnet
|
38
|
+
url = nil # use default
|
39
|
+
options = {chain: chain, wif: posting_wif, url: url}
|
38
40
|
tx = Radiator::Transaction.new(options)
|
39
41
|
tx.operations << {
|
40
42
|
type: :claim_reward_balance,
|
@@ -60,7 +62,9 @@ task :test_live_stream, [:chain, :persist] do |t, args|
|
|
60
62
|
chain = args[:chain] || 'steem'
|
61
63
|
persist = (args[:persist] || 'true') == 'true'
|
62
64
|
last_block_number = 0
|
63
|
-
|
65
|
+
# url = 'https://testnet.steemitdev.com/'
|
66
|
+
url = nil # use default
|
67
|
+
options = {chain: chain, persist: persist, url: url}
|
64
68
|
total_ops = 0.0
|
65
69
|
total_vops = 0.0
|
66
70
|
elapsed = 0
|
@@ -84,11 +88,13 @@ task :test_live_stream, [:chain, :persist] do |t, args|
|
|
84
88
|
ap error
|
85
89
|
end
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
91
|
+
puts "Problem: vops is nil!" if vops.nil?
|
92
|
+
|
93
|
+
# Did we reach this point with an unhandled error that wasn't retried?
|
94
|
+
# If so, vops might be nil and we might need this error to get handled
|
95
|
+
# instead of checking for vops.nil?.
|
96
|
+
|
97
|
+
vop_size = vops.size
|
92
98
|
total_vops += vop_size
|
93
99
|
|
94
100
|
vop_ratio = if total_vops > 0
|
data/lib/radiator/api.rb
CHANGED
@@ -429,12 +429,15 @@ module Radiator
|
|
429
429
|
response = JSON[body]
|
430
430
|
|
431
431
|
if response['id'] != options[:id]
|
432
|
+
debug_payload(options, body) if ENV['DEBUG'] == 'true'
|
433
|
+
|
432
434
|
if !!response['id']
|
433
435
|
warning "Unexpected rpc_id (expected: #{options[:id]}, got: #{response['id']}), retrying ...", method_name, true
|
434
436
|
else
|
435
437
|
# The node has broken the jsonrpc spec.
|
436
438
|
warning "Node did not provide jsonrpc id (expected: #{options[:id]}, got: nothing, retrying ...", method_name, true
|
437
439
|
end
|
440
|
+
|
438
441
|
if response.keys.include?('error')
|
439
442
|
handle_error(response, options, method_name, tries)
|
440
443
|
end
|
@@ -835,6 +838,20 @@ module Radiator
|
|
835
838
|
end
|
836
839
|
end
|
837
840
|
|
841
|
+
def debug_payload(request, response)
|
842
|
+
request = JSON.pretty_generate(request)
|
843
|
+
response = JSON.parse(response) rescue response
|
844
|
+
response = JSON.pretty_generate(response) rescue response
|
845
|
+
|
846
|
+
puts '=' * 80
|
847
|
+
puts "Request:"
|
848
|
+
puts request
|
849
|
+
puts '=' * 80
|
850
|
+
puts "Response:"
|
851
|
+
puts response
|
852
|
+
puts '=' * 80
|
853
|
+
end
|
854
|
+
|
838
855
|
def backoff
|
839
856
|
shutdown
|
840
857
|
bump_failover if flappy? || !healthy?(uri)
|
@@ -87,14 +87,20 @@ module Radiator
|
|
87
87
|
@api_name = data_call_method['call.params']
|
88
88
|
end
|
89
89
|
else
|
90
|
-
@error_code = ['code']
|
91
|
-
@error_message = ['message']
|
90
|
+
@error_code = @error['code']
|
91
|
+
@error_message = @error['message']
|
92
92
|
@expiry = false
|
93
93
|
@can_retry = false
|
94
94
|
@can_reprepare = false
|
95
95
|
end
|
96
96
|
|
97
97
|
case @error_code
|
98
|
+
when -32603
|
99
|
+
if error_match?('Internal Error')
|
100
|
+
@expiry = false
|
101
|
+
@can_retry = true
|
102
|
+
@can_reprepare = true
|
103
|
+
end
|
98
104
|
when -32003
|
99
105
|
if error_match?('Unable to acquire database lock')
|
100
106
|
@expiry = false
|
@@ -148,7 +154,11 @@ module Radiator
|
|
148
154
|
@can_reprepare = false
|
149
155
|
end
|
150
156
|
rescue => e
|
151
|
-
|
157
|
+
if ENV['DEBUG'] == 'true'
|
158
|
+
ap error_parser_exception: e, original_response: response, backtrace: e.backtrace
|
159
|
+
else
|
160
|
+
ap error_parser_exception: e, original_response: response
|
161
|
+
end
|
152
162
|
|
153
163
|
@expiry = false
|
154
164
|
@can_retry = false
|
@@ -161,8 +171,14 @@ module Radiator
|
|
161
171
|
|
162
172
|
case @error['code']
|
163
173
|
when -32003
|
174
|
+
any_of = [
|
175
|
+
'Internal Error"',
|
176
|
+
'_api_plugin not enabled.'
|
177
|
+
]
|
178
|
+
|
164
179
|
can_retry = error_match?('Unable to acquire database lock')
|
165
|
-
|
180
|
+
|
181
|
+
if !can_retry && error_match?(any_of)
|
166
182
|
can_retry = true
|
167
183
|
@node_degraded = true
|
168
184
|
else
|
@@ -177,18 +193,24 @@ module Radiator
|
|
177
193
|
can_retry
|
178
194
|
end
|
179
195
|
|
180
|
-
def error_match?(
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
196
|
+
def error_match?(matches)
|
197
|
+
matches = [matches].flatten
|
198
|
+
|
199
|
+
any = matches.map do |match|
|
200
|
+
case match
|
201
|
+
when String
|
202
|
+
@error['message'] && @error['message'].include?(match)
|
203
|
+
when Array
|
204
|
+
if @error['message']
|
205
|
+
match.map { |m| m.include?(match) }.include? true
|
206
|
+
else
|
207
|
+
false
|
208
|
+
end
|
209
|
+
else; false
|
189
210
|
end
|
190
|
-
else; false
|
191
211
|
end
|
212
|
+
|
213
|
+
any.include?(true)
|
192
214
|
end
|
193
215
|
|
194
216
|
def to_s
|
data/lib/radiator/transaction.rb
CHANGED
@@ -172,7 +172,8 @@ module Radiator
|
|
172
172
|
|
173
173
|
@api.get_block(block_number) do |block, error|
|
174
174
|
if !!error
|
175
|
-
|
175
|
+
ap error if ENV['DEBUG'] == 'true'
|
176
|
+
raise TransactionError, "Unable to prepare transaction: #{error.message || 'Unknown cause.'}"
|
176
177
|
end
|
177
178
|
|
178
179
|
if !!block && !!block.previous
|
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.0pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|