radiator 0.3.0 → 0.3.1
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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/radiator/api.rb +44 -9
- data/lib/radiator/chain_config.rb +1 -1
- data/lib/radiator/stream.rb +1 -2
- data/lib/radiator/transaction.rb +1 -1
- data/lib/radiator/version.rb +1 -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: 1f5f2643bbb6354a779623e8f20d7be5f5d83249
|
4
|
+
data.tar.gz: 327db2a8c46cd416de62ed449fac46af45333f54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0bbb1950e374f28f15f532b6839bf93c39436e489fef70c22cea2cb77e2e94bc7fd6d184d5199aa7235be07cf917a04b42aded9eca185d1c33786131af7b05c
|
7
|
+
data.tar.gz: 02c0666cdb6eaa058826608e630a3f4baf5ce89c3116e401d6d608a695132a6242a5c72fd0ee61d42f5a883558929132428f2e3bc70989016cdfa46f28439ad8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -376,7 +376,7 @@ tx.process(true)
|
|
376
376
|
Radiator also supports Golos. To use the Golos blockchain, provide a node and chain_id:
|
377
377
|
|
378
378
|
```ruby
|
379
|
-
tx = Radiator::Transaction.new(wif: 'Your Wif Here', chain: :golos, url: 'https://
|
379
|
+
tx = Radiator::Transaction.new(wif: 'Your Wif Here', chain: :golos, url: 'https://ws.golos.io')
|
380
380
|
vote = {
|
381
381
|
type: :vote,
|
382
382
|
voter: 'xeroc',
|
data/lib/radiator/api.rb
CHANGED
@@ -131,10 +131,12 @@ module Radiator
|
|
131
131
|
# @see https://steemit.github.io/steemit-docs/#accounts
|
132
132
|
#
|
133
133
|
class Api
|
134
|
-
|
134
|
+
DEFAULT_STEEM_URL = 'https://steemd.steemit.com'
|
135
135
|
|
136
|
-
|
137
|
-
|
136
|
+
DEFAULT_GOLOS_URL = 'https://ws.golos.io'
|
137
|
+
|
138
|
+
DEFAULT_STEEM_FAILOVER_URLS = [
|
139
|
+
DEFAULT_STEEM_URL,
|
138
140
|
'https://steemd-int.steemit.com',
|
139
141
|
'https://steemd.steemitstage.com',
|
140
142
|
'https://gtg.steem.house:8090',
|
@@ -144,11 +146,35 @@ module Radiator
|
|
144
146
|
'https://rpc.steemliberator.com'
|
145
147
|
]
|
146
148
|
|
149
|
+
DEFAULT_GOLOS_FAILOVER_URLS = [
|
150
|
+
DEFAULT_GOLOS_URL
|
151
|
+
]
|
152
|
+
|
147
153
|
# @private
|
148
154
|
POST_HEADERS = {
|
149
155
|
'Content-Type' => 'application/json'
|
150
156
|
}
|
151
157
|
|
158
|
+
# These are known SSL versions supported by:
|
159
|
+
# https://github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb
|
160
|
+
SSL_VERSIONS = [:TLSv1_2, :TLSv1_1, :TLSv1, :SSLv3, :SSLv2, :SSLv23]
|
161
|
+
|
162
|
+
def self.default_url(chain)
|
163
|
+
case chain.to_sym
|
164
|
+
when :steem then DEFAULT_STEEM_URL
|
165
|
+
when :golos then DEFAULT_GOLOS_URL
|
166
|
+
else; raise ApiError, "Unsupported chain: #{chain}"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.default_failover_urls(chain)
|
171
|
+
case chain.to_sym
|
172
|
+
when :steem then DEFAULT_STEEM_FAILOVER_URLS
|
173
|
+
when :golos then DEFAULT_GOLOS_FAILOVER_URLS
|
174
|
+
else; raise ApiError, "Unsupported chain: #{chain}"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
152
178
|
# Cretes a new instance of Radiator::Api.
|
153
179
|
#
|
154
180
|
# Examples:
|
@@ -164,16 +190,18 @@ module Radiator
|
|
164
190
|
def initialize(options = {})
|
165
191
|
@user = options[:user]
|
166
192
|
@password = options[:password]
|
167
|
-
@
|
193
|
+
@chain = options[:chain] || :steem
|
194
|
+
@url = options[:url] || Api::default_url(@chain)
|
168
195
|
@preferred_url = @url.dup
|
169
196
|
@failover_urls = options[:failover_urls]
|
170
197
|
@debug = !!options[:debug]
|
171
198
|
@logger = options[:logger] || Radiator.logger
|
172
199
|
@hashie_logger = options[:hashie_logger] || Logger.new(nil)
|
173
200
|
@max_requests = options[:max_requests] || 30
|
201
|
+
@ssl_version = nil # default
|
174
202
|
|
175
203
|
if @failover_urls.nil?
|
176
|
-
@failover_urls =
|
204
|
+
@failover_urls = Api::default_failover_urls(@chain) - [@url]
|
177
205
|
end
|
178
206
|
|
179
207
|
@failover_urls = [@failover_urls].flatten.compact
|
@@ -191,7 +219,7 @@ module Radiator
|
|
191
219
|
|
192
220
|
Hashie.logger = @hashie_logger
|
193
221
|
@method_names = nil
|
194
|
-
@api_options = options.dup
|
222
|
+
@api_options = options.dup.merge(chain: @chain)
|
195
223
|
end
|
196
224
|
|
197
225
|
# Get a specific block or range of blocks.
|
@@ -419,7 +447,8 @@ module Radiator
|
|
419
447
|
rescue RangeError => e
|
420
448
|
warning 'Range Error, retrying ...', method_name
|
421
449
|
rescue OpenSSL::SSL::SSLError => e
|
422
|
-
|
450
|
+
@ssl_version = SSL_VERSIONS.sample
|
451
|
+
warning "SSL Error (#{e.message}), switching to #{@ssl_version} and retrying ...", method_name
|
423
452
|
rescue SocketError => e
|
424
453
|
warning "Socket Error (#{e.message}), retrying ...", method_name
|
425
454
|
rescue JSON::ParserError => e
|
@@ -485,7 +514,13 @@ module Radiator
|
|
485
514
|
http.idle_timeout = idempotent ? 10 : nil
|
486
515
|
http.max_requests = @max_requests
|
487
516
|
http.retry_change_requests = idempotent
|
488
|
-
|
517
|
+
|
518
|
+
if flappy?
|
519
|
+
http.reuse_ssl_sessions = false
|
520
|
+
http.ssl_version = @ssl_version
|
521
|
+
else
|
522
|
+
http.reuse_ssl_sessions = true
|
523
|
+
end
|
489
524
|
end
|
490
525
|
end
|
491
526
|
|
@@ -573,7 +608,7 @@ module Radiator
|
|
573
608
|
@backoff_sleep *= 2
|
574
609
|
sleep @backoff_sleep
|
575
610
|
|
576
|
-
if Time.now - @backoff_at > 300
|
611
|
+
if !!@backoff_at && Time.now - @backoff_at > 300
|
577
612
|
@backoff_at = nil
|
578
613
|
@backoff_sleep = nil
|
579
614
|
end
|
@@ -15,7 +15,7 @@ module Radiator
|
|
15
15
|
NETWORKS_GOLOS_CORE_ASSET = 'GOLOS'
|
16
16
|
NETWORKS_GOLOS_DEBT_ASSET = 'GBG'
|
17
17
|
NETWORKS_GOLOS_VEST_ASSET = 'GESTS'
|
18
|
-
NETWORKS_GOLOS_DEFAULT_NODE = 'https://
|
18
|
+
NETWORKS_GOLOS_DEFAULT_NODE = 'https://ws.golos.io'
|
19
19
|
|
20
20
|
NETWORKS_TEST_CHAIN_ID = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'
|
21
21
|
NETWORKS_TEST_ADDRESS_PREFIX = 'TST'
|
data/lib/radiator/stream.rb
CHANGED
data/lib/radiator/transaction.rb
CHANGED
data/lib/radiator/version.rb
CHANGED