radiator 0.4.0pre4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fa87cf414d03f44944ae568a7c96b6c7e268d7c
4
- data.tar.gz: 14b86e6768d73cc4842497c8b91547e6cd2add46
3
+ metadata.gz: 20a5af6853cd421c70122a70ff48cc4822e7c58c
4
+ data.tar.gz: 2f303245c66ce3f4ee7d7ad7a1050bd18221c0b1
5
5
  SHA512:
6
- metadata.gz: 577386edefce45ef60a51476db9b1f76a44a096ac149cdb61fc992af391420a2c35a40fe797921fb9ddc1a6765895e9eff5d636ad378555d0f550e058dd608c9
7
- data.tar.gz: 40432819def16218dbc7fa51099791138c4afb1282e7e6c5eb066cee5b0bf4d16245f2e411d4aa5b3de8be73e4a2dedf35343c606d0b3642eb633a566310d0b6
6
+ metadata.gz: a42aa75fa026a2ea1e0e6dfb25d22c1769eab3672e28616762df741ea523135389980b1299c863ca6886ddd643b72f146f97569f47f0b332c9e2d6565593fa4d
7
+ data.tar.gz: ba2fa368c835473f96519c909818a645e8d416e4061ea28b34c5b1d5a575b3188acaa7601aa1dd2ae6d4d12086950b73501d2215271dd70924dbd15e18806be1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- radiator (0.4.0pre4)
4
+ radiator (0.4.0)
5
5
  awesome_print (~> 1.7, >= 1.7.0)
6
6
  bitcoin-ruby (~> 0.0, >= 0.0.11)
7
7
  ffi (~> 1.9, >= 1.9.18)
@@ -32,7 +32,7 @@ GEM
32
32
  multi_json (~> 1.10)
33
33
  method_source (0.9.0)
34
34
  minitest (5.11.3)
35
- minitest-line (0.6.4)
35
+ minitest-line (0.6.5)
36
36
  minitest (~> 5.0)
37
37
  minitest-proveit (1.0.0)
38
38
  minitest (> 5, < 7)
@@ -51,7 +51,7 @@ GEM
51
51
  simplecov-html (~> 0.10.0)
52
52
  simplecov-html (0.10.2)
53
53
  vcr (3.0.3)
54
- webmock (3.3.0)
54
+ webmock (3.4.1)
55
55
  addressable (>= 2.3.6)
56
56
  crack (>= 0.3.2)
57
57
  hashdiff
data/README.md CHANGED
@@ -13,7 +13,7 @@ Radiator is an API Client for interaction with the STEEM network using Ruby.
13
13
  #### Changes in v0.4.0
14
14
 
15
15
  * Gem updates
16
- * AppBase Support
16
+ * **AppBase Support**
17
17
  * Defaulting to `condenser_api.*` in `Radiator::Api` (see below)
18
18
  * Handle/recover from new `AppBase` errors.
19
19
  * `Radiator::Stream` now detects if it's stalled and takes action if it has to wait too long for a new block.
@@ -425,24 +425,6 @@ tx.operations << transfer
425
425
  tx.process(true)
426
426
  ```
427
427
 
428
- #### Golos
429
-
430
- Radiator also supports Golos. To use the Golos blockchain, provide a node and chain_id:
431
-
432
- ```ruby
433
- tx = Radiator::Transaction.new(wif: 'Your Wif Here', chain: :golos, url: 'https://ws.golos.io')
434
- vote = {
435
- type: :vote,
436
- voter: 'xeroc',
437
- author: 'xeroc',
438
- permlink: 'piston',
439
- weight: 10000
440
- }
441
-
442
- tx.operations << vote
443
- tx.process(true)
444
- ```
445
-
446
428
  There's a complete list of operations known to Radiator in [`broadcast_operations.json`](https://github.com/inertia186/radiator/blob/master/lib/radiator/broadcast_operations.json).
447
429
 
448
430
  ## Failover
@@ -451,10 +433,10 @@ Radiator supports failover for situations where a node has, for example, become
451
433
 
452
434
  ```ruby
453
435
  options = {
454
- ur: 'https://api.steemit.com',
436
+ url: 'https://api.steemit.com',
455
437
  failover_urls: [
456
438
  'https://api.steemitstage.com',
457
- 'https://gtg.steem.house:8090'
439
+ 'https://api.steem.house'
458
440
  ]
459
441
  }
460
442
 
@@ -475,6 +457,22 @@ There is another rare scenario involving `::Transaction` broadcasts that's handl
475
457
  tx = Radiator::Transaction.new(wif: wif, recover_transactions_on_error: false)
476
458
  ```
477
459
 
460
+ ### Golos Failover Examples
461
+
462
+ Typically, you only need to pass `chain: :golos` to enable Golos. Failover is enabled by default. If you want to provide your own full nodes, use this format:
463
+
464
+ ```ruby
465
+ options = {
466
+ chain: :golos,
467
+ url: 'https://ws.golos.io',
468
+ failover_urls: [
469
+ 'https://api.golos.cf'
470
+ ]
471
+ }
472
+
473
+ api = Radiator::Api.new(options)
474
+ ```
475
+
478
476
  ## Debugging
479
477
 
480
478
  To enable debugging, set environment `LOG=DEBUG` before launching your app. E.g.:
@@ -519,6 +517,34 @@ If you have excluded system resources as the root cause, then you should take a
519
517
 
520
518
  Verify your code is not doing too much between blocks.
521
519
 
520
+ ## Problem: I'm getting an endless loop: `#<OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=error: certificate verify failed>`
521
+
522
+ ## Solution:
523
+
524
+ You're probably creating too many threads or you don't have enough resources for what you're doing. One option for you is to avoid persistent HTTP by passing `persist: false`.
525
+
526
+ Doing this will impact performance because each API call will be a separate socket call. All of the constructors accept `persist: false`., e.g.:
527
+
528
+ ```ruby
529
+ api = Radiator::Api.new(persist: false)
530
+ ```
531
+
532
+ ... or ...
533
+
534
+ ```ruby
535
+ stream = Radiator::Stream.new(persist: false)
536
+ ```
537
+
538
+ ... or ...
539
+
540
+ ```ruby
541
+ tx = Radiator::Transaction.new(options.merge(persist: false, wif: wif))
542
+ ```
543
+
544
+ Also see troubleshooting discussion about this situation:
545
+
546
+ https://github.com/inertia186/radiator/issues/12
547
+
522
548
  ## Tests
523
549
 
524
550
  * Clone the client repository into a directory of your choice:
@@ -531,15 +557,13 @@ Verify your code is not doing too much between blocks.
531
557
  * `HELL_ENABLED=true rake`
532
558
  * To run a stream test on the live STEEM blockchain with debug logging enabled:
533
559
  * `LOG=DEBUG rake test_live_stream`
534
- * To run a stream test on the live GOLOS blockchain with debug logging enabled:
535
- * `LOG=DEBUG rake test_live_stream[golos]`
536
560
  ---
537
561
 
538
562
  <center>
539
563
  <img src="http://www.steemimg.com/images/2016/08/19/RadiatorCoolingFan-54in-Webfdcb1.png" />
540
564
  </center>
541
565
 
542
- See my previous Ruby How To posts in: [#radiator](https://steemit.com/created/radiator) [#ruby](https://steemit.com/created/ruby)
566
+ See my previous Ruby How To posts in: [/f/ruby](https://chainbb.com/f/ruby)
543
567
 
544
568
  ## Get in touch!
545
569
 
data/Rakefile CHANGED
@@ -3,7 +3,6 @@ require 'rake/testtask'
3
3
  require 'yard'
4
4
  require 'radiator'
5
5
  require 'awesome_print'
6
- require 'pry'
7
6
 
8
7
  Rake::TestTask.new(:test) do |t|
9
8
  t.libs << 'test'
@@ -85,7 +84,7 @@ task :test_live_stream, [:chain, :persist] do |t, args|
85
84
  api.get_ops_in_block(n, true) do |vops, error|
86
85
  if !!error
87
86
  puts "Error on get_ops_in_block for block #{n}"
88
- ap error
87
+ ap error if defined? ap
89
88
  end
90
89
 
91
90
  puts "Problem: vops is nil!" if vops.nil?
data/lib/radiator/api.rb CHANGED
@@ -136,13 +136,10 @@ module Radiator
136
136
 
137
137
  DEFAULT_STEEM_URL = 'https://api.steemit.com'
138
138
 
139
- DEFAULT_GOLOS_URL = 'https://ws.golos.io'
140
-
141
139
  DEFAULT_STEEM_FAILOVER_URLS = [
142
140
  DEFAULT_STEEM_URL,
143
141
  'https://api.steemitstage.com',
144
142
  'https://appbasetest.timcliff.com',
145
- 'https://gtg.steem.house:8090',
146
143
  'https://api.steem.house',
147
144
  'https://seed.bitcoiner.me',
148
145
  'https://steemd.minnowsupportproject.org',
@@ -155,16 +152,6 @@ module Radiator
155
152
  'https://steemd.steemgigs.org'
156
153
  ]
157
154
 
158
- DEFAULT_GOLOS_FAILOVER_URLS = [
159
- DEFAULT_GOLOS_URL,
160
- 'https://api.golos.cf',
161
- # not recommended, not all plug-ins enabled:
162
- # 'https://ws.goldvoice.club',
163
- # 'http://golos-seed.arcange.eu',
164
- # not recommended, requires option ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
165
- # 'https://golos-seed.arcange.eu',
166
- ]
167
-
168
155
  # @private
169
156
  POST_HEADERS = {
170
157
  'Content-Type' => 'application/json',
@@ -177,7 +164,6 @@ module Radiator
177
164
  def self.default_url(chain)
178
165
  case chain.to_sym
179
166
  when :steem then DEFAULT_STEEM_URL
180
- when :golos then DEFAULT_GOLOS_URL
181
167
  else; raise ApiError, "Unsupported chain: #{chain}"
182
168
  end
183
169
  end
@@ -185,7 +171,6 @@ module Radiator
185
171
  def self.default_failover_urls(chain)
186
172
  case chain.to_sym
187
173
  when :steem then DEFAULT_STEEM_FAILOVER_URLS
188
- when :golos then DEFAULT_GOLOS_FAILOVER_URLS
189
174
  else; raise ApiError, "Unsupported chain: #{chain}"
190
175
  end
191
176
  end
@@ -204,6 +189,7 @@ module Radiator
204
189
  # @option options [Integer] :max_requests Maximum number of requests on a connection before it is considered expired and automatically closed.
205
190
  # @option options [Integer] :pool_size Maximum number of connections allowed.
206
191
  # @option options [Boolean] :reuse_ssl_sessions Reuse a previously opened SSL session for a new connection. There's a slight performance improvement by enabling this, but at the expense of reliability during long execution. Default false.
192
+ # @option options [Boolean] :persist Enable or disable Persistent HTTP. Using Persistent HTTP keeps the connection alive between API calls. Default: `true`
207
193
  def initialize(options = {})
208
194
  @user = options[:user]
209
195
  @password = options[:password]
@@ -400,6 +386,10 @@ module Radiator
400
386
  loop do
401
387
  tries += 1
402
388
 
389
+ if tries > 5 && flappy? && !check_file_open?
390
+ raise ApiError, 'PANIC: Out of file resources'
391
+ end
392
+
403
393
  begin
404
394
  if tries > 1 && @recover_transactions_on_error && api_name == :network_broadcast_api
405
395
  signatures, exp = extract_signatures(options)
@@ -435,7 +425,7 @@ module Radiator
435
425
  warning "Unexpected rpc_id (expected: #{options[:id]}, got: #{response['id']}), retrying ...", method_name, true
436
426
  else
437
427
  # The node has broken the jsonrpc spec.
438
- warning "Node did not provide jsonrpc id (expected: #{options[:id]}, got: nothing, retrying ...", method_name, true
428
+ warning "Node did not provide jsonrpc id (expected: #{options[:id]}, got: nothing), retrying ...", method_name, true
439
429
  end
440
430
 
441
431
  if response.keys.include?('error')
@@ -675,7 +665,6 @@ module Radiator
675
665
 
676
666
  api.get_blocks(block_range) do |block, block_num|
677
667
  unless defined? block.transaction_ids
678
- # Happens on Golos, see: https://github.com/GolosChain/golos/issues/281
679
668
  error "Blockchain does not provide transaction ids in blocks, giving up."
680
669
  return nil
681
670
  end
@@ -683,6 +672,16 @@ module Radiator
683
672
  count += 1
684
673
  raise ApiError, "Race condition detected on remote node at: #{block_num}" if block.nil?
685
674
 
675
+ # TODO Some blockchains (like Golos) do not have transaction_ids. In
676
+ # the future, it would be better to decode the operation and signature
677
+ # into the transaction id.
678
+ # See: https://github.com/steemit/steem/issues/187
679
+ # See: https://github.com/GolosChain/golos/issues/281
680
+ unless defined? block.transaction_ids
681
+ @recover_transactions_on_error = false
682
+ return
683
+ end
684
+
686
685
  timestamp = Time.parse(block.timestamp + 'Z')
687
686
  break if timestamp < after
688
687
 
@@ -867,5 +866,17 @@ module Radiator
867
866
  @backoff_sleep = nil
868
867
  end
869
868
  end
869
+
870
+ def self.finalize(logger, hashie_logger)
871
+ proc {
872
+ if !!logger && defined?(logger.close) && !logger.closed?
873
+ logger.close
874
+ end
875
+
876
+ if !!hashie_logger && defined?(hashie_logger.close) && !hashie_logger.closed?
877
+ hashie_logger.close
878
+ end
879
+ }
880
+ end
870
881
  end
871
882
  end
@@ -291,7 +291,6 @@ module Radiator
291
291
  def default_debt_asset
292
292
  case chain
293
293
  when :steem then ChainConfig::NETWORKS_STEEM_DEBT_ASSET
294
- when :golos then ChainConfig::NETWORKS_GOLOS_DEBT_ASSET
295
294
  when :test then ChainConfig::NETWORKS_TEST_DEBT_ASSET
296
295
  else; raise ChainError, "Unknown chain: #{chain}"
297
296
  end
@@ -10,13 +10,6 @@ module Radiator
10
10
  NETWORKS_STEEM_VEST_ASSET = 'VESTS'
11
11
  NETWORKS_STEEM_DEFAULT_NODE = 'https://api.steemit.com'
12
12
 
13
- NETWORKS_GOLOS_CHAIN_ID = '782a3039b478c839e4cb0c941ff4eaeb7df40bdd68bd441afd444b9da763de12'
14
- NETWORKS_GOLOS_ADDRESS_PREFIX = 'GLS'
15
- NETWORKS_GOLOS_CORE_ASSET = 'GOLOS'
16
- NETWORKS_GOLOS_DEBT_ASSET = 'GBG'
17
- NETWORKS_GOLOS_VEST_ASSET = 'GESTS'
18
- NETWORKS_GOLOS_DEFAULT_NODE = 'https://ws.golos.io'
19
-
20
13
  NETWORKS_TEST_CHAIN_ID = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'
21
14
  NETWORKS_TEST_ADDRESS_PREFIX = 'TST'
22
15
  NETWORKS_TEST_CORE_ASSET = 'CORE'
@@ -24,6 +17,6 @@ module Radiator
24
17
  NETWORKS_TEST_VEST_ASSET = 'CESTS'
25
18
  NETWORKS_TEST_DEFAULT_NODE = 'https://test.steem.ws'
26
19
 
27
- NETWORK_CHAIN_IDS = [NETWORKS_STEEM_CHAIN_ID, NETWORKS_GOLOS_CHAIN_ID, NETWORKS_TEST_CHAIN_ID]
20
+ NETWORK_CHAIN_IDS = [NETWORKS_STEEM_CHAIN_ID, NETWORKS_TEST_CHAIN_ID]
28
21
  end
29
22
  end
@@ -1,5 +1,3 @@
1
- require 'awesome_print'
2
-
3
1
  module Radiator
4
2
  class ErrorParser
5
3
  include Utils
@@ -154,10 +152,12 @@ module Radiator
154
152
  @can_reprepare = false
155
153
  end
156
154
  rescue => e
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
155
+ if defined? ap
156
+ if ENV['DEBUG'] == 'true'
157
+ ap error_parser_exception: e, original_response: response, backtrace: e.backtrace
158
+ else
159
+ ap error_parser_exception: e, original_response: response
160
+ end
161
161
  end
162
162
 
163
163
  @expiry = false
@@ -75,7 +75,6 @@ module Radiator
75
75
 
76
76
  case chain.to_s.downcase.to_sym
77
77
  when :steem then NETWORKS_STEEM_CHAIN_ID
78
- when :golos then NETWORKS_GOLOS_CHAIN_ID
79
78
  when :test then NETWORKS_TEST_CHAIN_ID
80
79
  end
81
80
  end
@@ -83,7 +82,6 @@ module Radiator
83
82
  def url
84
83
  case chain.to_s.downcase.to_sym
85
84
  when :steem then NETWORKS_STEEM_DEFAULT_NODE
86
- when :golos then NETWORKS_GOLOS_DEFAULT_NODE
87
85
  when :test then NETWORKS_TEST_DEFAULT_NODE
88
86
  end
89
87
  end
@@ -172,7 +170,7 @@ module Radiator
172
170
 
173
171
  @api.get_block(block_number) do |block, error|
174
172
  if !!error
175
- ap error if ENV['DEBUG'] == 'true'
173
+ ap error if defined?(ap) && ENV['DEBUG'] == 'true'
176
174
  raise TransactionError, "Unable to prepare transaction: #{error.message || 'Unknown cause.'}"
177
175
  end
178
176
 
@@ -23,9 +23,6 @@ module Radiator
23
23
  when 'STEEM' then 3
24
24
  when 'VESTS' then 6
25
25
  when 'SBD' then 3
26
- when 'GOLOS' then 3
27
- when 'GESTS' then 6
28
- when 'GBG' then 3
29
26
  when 'CORE' then 3
30
27
  when 'CESTS' then 6
31
28
  when 'TEST' then 3
@@ -39,10 +39,18 @@ module Radiator
39
39
  puts "#{level}: #{log_message}"
40
40
  end
41
41
  else
42
- if !!prefix
43
- @logger.ap log_level: level, prefix => obj
42
+ if defined? @logger.ap
43
+ if !!prefix
44
+ @logger.ap log_level: level, prefix => obj
45
+ else
46
+ @logger.ap obj, level
47
+ end
44
48
  else
45
- @logger.ap obj, level
49
+ if !!prefix
50
+ @logger.send level, ({prefix => obj}).inspect
51
+ else
52
+ @logger.send level, obj.inspect
53
+ end
46
54
  end
47
55
  end
48
56
 
@@ -1,4 +1,4 @@
1
1
  module Radiator
2
- VERSION = '0.4.0pre4'
2
+ VERSION = '0.4.0'
3
3
  AGENT_ID = "radiator/#{VERSION}"
4
4
  end
data/lib/radiator.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'radiator/version'
2
2
  require 'json'
3
+ require 'awesome_print' if ENV['USE_AWESOME_PRINT'] == 'true'
3
4
 
4
5
  module Radiator
5
6
  require 'radiator/utils'
@@ -38,6 +39,5 @@ module Radiator
38
39
  require 'radiator/mixins/acts_as_wallet'
39
40
  require 'radiator/chain'
40
41
  require 'steem'
41
- require 'golos'
42
42
  extend self
43
43
  end
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.0pre4
4
+ version: 0.4.0
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-28 00:00:00.000000000 Z
11
+ date: 2018-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -345,7 +345,6 @@ files:
345
345
  - images/Anthony Martin.png
346
346
  - images/Marvin Hofmann.jpg
347
347
  - images/Marvin Hofmann.png
348
- - lib/golos.rb
349
348
  - lib/radiator.rb
350
349
  - lib/radiator/account_by_key_api.rb
351
350
  - lib/radiator/account_history_api.rb
@@ -402,9 +401,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
402
401
  version: '0'
403
402
  required_rubygems_version: !ruby/object:Gem::Requirement
404
403
  requirements:
405
- - - ">"
404
+ - - ">="
406
405
  - !ruby/object:Gem::Version
407
- version: 1.3.1
406
+ version: '0'
408
407
  requirements: []
409
408
  rubyforge_project:
410
409
  rubygems_version: 2.6.14
data/lib/golos.rb DELETED
@@ -1,11 +0,0 @@
1
- # Golos chain client for broadcasting common operations.
2
- #
3
- # @see Radiator::Chain
4
- class Golos < Radiator::Chain
5
- def initialize(options = {})
6
- super(options.merge(chain: :golos))
7
- end
8
-
9
- alias golos_per_mgest base_per_mvest
10
- alias golos_per_gbg base_per_debt
11
- end