radiator 0.4.6 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +27 -12
  3. data/Rakefile +53 -23
  4. data/lib/radiator.rb +3 -1
  5. data/lib/radiator/api.rb +111 -16
  6. data/lib/radiator/bridge.rb +34 -0
  7. data/lib/radiator/broadcast_operations.json +7 -7
  8. data/lib/radiator/chain.rb +1 -1
  9. data/lib/radiator/chain_config.rb +9 -2
  10. data/lib/radiator/database_api.rb +1 -1
  11. data/lib/radiator/error_parser.rb +1 -1
  12. data/lib/radiator/follow_api.rb +1 -1
  13. data/lib/radiator/market_history_api.rb +1 -1
  14. data/lib/radiator/mixins/acts_as_poster.rb +4 -4
  15. data/lib/radiator/operation.rb +3 -2
  16. data/lib/radiator/operation_types.rb +43 -27
  17. data/lib/radiator/ssc/base_steem_smart_contract_rpc.rb +1 -1
  18. data/lib/radiator/stream.rb +21 -8
  19. data/lib/radiator/transaction.rb +43 -3
  20. data/lib/radiator/type/amount.rb +8 -50
  21. data/lib/radiator/type/beneficiaries.rb +8 -1
  22. data/lib/radiator/type/price.rb +2 -2
  23. data/lib/radiator/version.rb +1 -1
  24. data/radiator.gemspec +17 -13
  25. data/test/fixtures/empty.json +1 -0
  26. data/test/fixtures/error.json +29 -0
  27. data/test/fixtures/follow_api_get_followers.json +1 -0
  28. data/test/fixtures/get_account.json +165 -0
  29. data/test/fixtures/get_account_count.json +1 -0
  30. data/test/fixtures/get_account_references.json +1 -0
  31. data/test/fixtures/get_block.json +193 -0
  32. data/test/fixtures/get_dynamic_global_properties.json +32 -0
  33. data/test/fixtures/get_feed_history.json +684 -0
  34. data/test/fixtures/get_hardfork_version.json +1 -0
  35. data/test/fixtures/get_key_references.json +14 -0
  36. data/test/fixtures/get_stats_for_time.json +57 -0
  37. data/test/fixtures/get_vesting_delegation.json +936 -0
  38. data/test/fixtures/golos_get_dynamic_global_properties.json +32 -0
  39. data/test/fixtures/market_history_api_get_market_history_buckets.json +1 -0
  40. data/test/fixtures/market_history_api_get_order_book.json +109 -0
  41. data/test/fixtures/market_history_api_get_recent_trades.json +55 -0
  42. data/test/fixtures/market_history_api_get_ticker.json +11 -0
  43. data/test/fixtures/market_history_api_get_volume.json +1 -0
  44. data/test/fixtures/null.json +1 -0
  45. data/test/fixtures/vcr_cassettes/account_by_key_api_all_methods.yml +1465 -0
  46. data/test/fixtures/vcr_cassettes/account_by_key_api_jsonrpc.yml +199 -0
  47. data/test/fixtures/vcr_cassettes/api_all_methods.yml +13802 -0
  48. data/test/fixtures/vcr_cassettes/api_jsonrpc.yml +53 -0
  49. data/test/fixtures/vcr_cassettes/base_per_debt.yml +11068 -0
  50. data/test/fixtures/vcr_cassettes/base_per_mvest.yml +6024 -0
  51. data/test/fixtures/vcr_cassettes/block_time.yml +5368 -0
  52. data/test/fixtures/vcr_cassettes/broadcast_transaction.yml +1723 -0
  53. data/test/fixtures/vcr_cassettes/chain_stats_api_jsonrpc.yml +51 -0
  54. data/test/fixtures/vcr_cassettes/condenser_all_all_methods.yml +13770 -0
  55. data/test/fixtures/vcr_cassettes/condenser_api_jsonrpc.yml +103 -0
  56. data/test/fixtures/vcr_cassettes/expiration_initialize.yml +16108 -0
  57. data/test/fixtures/vcr_cassettes/find_account.yml +5732 -0
  58. data/test/fixtures/vcr_cassettes/find_block.yml +5322 -0
  59. data/test/fixtures/vcr_cassettes/find_comment.yml +16386 -0
  60. data/test/fixtures/vcr_cassettes/follow_api_jsonrpc.yml +99 -0
  61. data/test/fixtures/vcr_cassettes/get_account_count.yml +783 -0
  62. data/test/fixtures/vcr_cassettes/get_account_references.yml +773 -0
  63. data/test/fixtures/vcr_cassettes/get_accounts.yml +918 -0
  64. data/test/fixtures/vcr_cassettes/get_accounts_no_argument.yml +773 -0
  65. data/test/fixtures/vcr_cassettes/get_dynamic_global_properties.yml +893 -0
  66. data/test/fixtures/vcr_cassettes/get_feed_history.yml +1432 -0
  67. data/test/fixtures/vcr_cassettes/get_hardfork_version.yml +835 -0
  68. data/test/fixtures/vcr_cassettes/get_key_references.yml +1571 -0
  69. data/test/fixtures/vcr_cassettes/get_market_history.yml +1563 -0
  70. data/test/fixtures/vcr_cassettes/get_market_history_buckets.yml +1665 -0
  71. data/test/fixtures/vcr_cassettes/get_order_book.yml +1459 -0
  72. data/test/fixtures/vcr_cassettes/get_recent_trades.yml +1459 -0
  73. data/test/fixtures/vcr_cassettes/get_ticker.yml +1563 -0
  74. data/test/fixtures/vcr_cassettes/get_trade_history.yml +1459 -0
  75. data/test/fixtures/vcr_cassettes/get_vesting_delegations.yml +731 -0
  76. data/test/fixtures/vcr_cassettes/get_volume.yml +1561 -0
  77. data/test/fixtures/vcr_cassettes/get_witness_by_account.yml +835 -0
  78. data/test/fixtures/vcr_cassettes/look_up_witnesses.yml +831 -0
  79. data/test/fixtures/vcr_cassettes/market_history_api_all_methods.yml +10191 -0
  80. data/test/fixtures/vcr_cassettes/market_history_api_jsonrpc.yml +51 -0
  81. data/test/fixtures/vcr_cassettes/network_broadcast_api_all_methods.yml +2455 -0
  82. data/test/fixtures/vcr_cassettes/network_broadcast_api_jsonrpc.yml +51 -0
  83. data/test/fixtures/vcr_cassettes/properties.yml +5551 -0
  84. data/test/fixtures/vcr_cassettes/recover_transaction.yml +1815 -0
  85. data/test/fixtures/vcr_cassettes/ssc_blockchain_block_info.yml +90 -0
  86. data/test/fixtures/vcr_cassettes/ssc_blockchain_block_info_invalid.yml +88 -0
  87. data/test/fixtures/vcr_cassettes/ssc_blockchain_latest_block_info.yml +90 -0
  88. data/test/fixtures/vcr_cassettes/ssc_blockchain_transaction_info.yml +90 -0
  89. data/test/fixtures/vcr_cassettes/ssc_contracts_contract.yml +364 -0
  90. data/test/fixtures/vcr_cassettes/ssc_contracts_find.yml +89 -0
  91. data/test/fixtures/vcr_cassettes/ssc_contracts_find_one.yml +87 -0
  92. data/test/fixtures/vcr_cassettes/stream_jsonrpc.yml +27502 -0
  93. data/test/fixtures/vcr_cassettes/tag_api_jsonrpc.yml +155 -0
  94. data/test/fixtures/vcr_cassettes/transaction_expiration_initialize_nil.yml +17597 -0
  95. data/test/fixtures/vcr_cassettes/transaction_jsonrpc.yml +61 -0
  96. data/test/fixtures/vcr_cassettes/unknown_chain_id.yml +13038 -0
  97. data/test/fixtures/vcr_cassettes/valid_chains.yml +11450 -0
  98. data/test/radiator/account_by_key_api_test.rb +46 -0
  99. data/test/radiator/api_test.rb +135 -0
  100. data/test/radiator/chain_stats_api_test.rb +49 -0
  101. data/test/radiator/chain_test.rb +153 -0
  102. data/test/radiator/condenser_api_test.rb +48 -0
  103. data/test/radiator/follow_api_test.rb +48 -0
  104. data/test/radiator/market_history_api_test.rb +100 -0
  105. data/test/radiator/network_broadcast_api_test.rb +48 -0
  106. data/test/radiator/operation_test.rb +116 -0
  107. data/test/radiator/ssc/blockchain_test.rb +58 -0
  108. data/test/radiator/ssc/contracts_test.rb +65 -0
  109. data/test/radiator/stream_test.rb +48 -0
  110. data/test/radiator/tag_api_test.rb +40 -0
  111. data/test/radiator/transaction_test.rb +755 -0
  112. data/test/test_helper.rb +66 -0
  113. metadata +187 -79
  114. data/.codeclimate.yml +0 -19
  115. data/.gitignore +0 -52
  116. data/.travis.yml +0 -23
  117. data/gource.sh +0 -8
  118. data/images/Anthony Martin.png +0 -0
  119. data/images/Marvin Hofmann.jpg +0 -0
  120. data/images/Marvin Hofmann.png +0 -0
  121. data/lib/steem.rb +0 -17
@@ -0,0 +1,34 @@
1
+ module Radiator
2
+ class Bridge < Api
3
+ def method_names
4
+ @method_names ||= [
5
+ :normalize_post,
6
+ :get_post_header,
7
+ :get_discussion,
8
+ :get_post,
9
+ :get_account_posts,
10
+ :get_ranked_posts,
11
+ :get_profile,
12
+ :get_trending_topics,
13
+ :get_relationship_between_accounts,
14
+ :post_notifications,
15
+ :account_notifications,
16
+ :unread_notifications,
17
+ :get_payout_stats,
18
+ :get_community,
19
+ :get_community_context,
20
+ :list_communities,
21
+ :list_pop_communities,
22
+ :list_community_roles,
23
+ :list_subscribers,
24
+ :list_all_subscriptions
25
+ ].freeze
26
+ end
27
+
28
+ def api_name
29
+ :bridge
30
+ end
31
+
32
+ def healthy?(_); true; end
33
+ end
34
+ end
@@ -195,7 +195,7 @@
195
195
  "author",
196
196
  "permlink",
197
197
  "max_accepted_payout",
198
- "percent_steem_dollars",
198
+ "percent_hbd",
199
199
  "allow_replies",
200
200
  "allow_votes",
201
201
  "allow_curation_rewards",
@@ -278,8 +278,8 @@
278
278
  "to",
279
279
  "agent",
280
280
  "escrow_id",
281
- "sbd_amount",
282
- "steem_amount",
281
+ "hbd_amount",
282
+ "hive_amount",
283
283
  "fee",
284
284
  "ratification_deadline",
285
285
  "escrow_expiration",
@@ -307,8 +307,8 @@
307
307
  "who",
308
308
  "receiver",
309
309
  "escrow_id",
310
- "sbd_amount",
311
- "steem_amount"
310
+ "hbd_amount",
311
+ "hive_amount"
312
312
  ]
313
313
  },
314
314
  {
@@ -399,8 +399,8 @@
399
399
  "operation": "claim_reward_balance",
400
400
  "params": [
401
401
  "account",
402
- "reward_steem",
403
- "reward_sbd",
402
+ "reward_hive",
403
+ "reward_hbd",
404
404
  "reward_vests"
405
405
  ]
406
406
  },
@@ -20,7 +20,7 @@ module Radiator
20
20
  # body: 'body of my post',
21
21
  # tags: ['tag'],
22
22
  # self_upvote: 10000,
23
- # percent_steem_dollars: 0
23
+ # percent_hbd: 0
24
24
  # }
25
25
  #
26
26
  # steem.post!(options)
@@ -10,6 +10,13 @@ module Radiator
10
10
  NETWORKS_STEEM_VEST_ASSET = 'VESTS'
11
11
  NETWORKS_STEEM_DEFAULT_NODE = 'https://api.steemit.com'
12
12
 
13
+ NETWORKS_HIVE_CHAIN_ID = 'beeab0de00000000000000000000000000000000000000000000000000000000'
14
+ NETWORKS_HIVE_ADDRESS_PREFIX = 'STM'
15
+ NETWORKS_HIVE_CORE_ASSET = 'HIVE'
16
+ NETWORKS_HIVE_DEBT_ASSET = 'HBD'
17
+ NETWORKS_HIVE_VEST_ASSET = 'VESTS'
18
+ NETWORKS_HIVE_DEFAULT_NODE = 'https://api.openhive.network'
19
+
13
20
  NETWORKS_TEST_CHAIN_ID = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'
14
21
  NETWORKS_TEST_ADDRESS_PREFIX = 'TST'
15
22
  NETWORKS_TEST_CORE_ASSET = 'CORE'
@@ -17,6 +24,6 @@ module Radiator
17
24
  NETWORKS_TEST_VEST_ASSET = 'CESTS'
18
25
  NETWORKS_TEST_DEFAULT_NODE = 'https://test.steem.ws'
19
26
 
20
- NETWORK_CHAIN_IDS = [NETWORKS_STEEM_CHAIN_ID, NETWORKS_TEST_CHAIN_ID]
27
+ NETWORK_CHAIN_IDS = [NETWORKS_STEEM_CHAIN_ID, NETWORKS_HIVE_CHAIN_ID, NETWORKS_TEST_CHAIN_ID]
21
28
  end
22
- end
29
+ end
@@ -2,4 +2,4 @@ module Radiator
2
2
  # @see Api
3
3
  class DatabaseApi < Api
4
4
  end
5
- end
5
+ end
@@ -69,7 +69,7 @@ module Radiator
69
69
  stack_formats = stacks.map { |s| s['format'] }
70
70
  stack_datum = stacks.map { |s| s['data'] }
71
71
  data_call_method = stack_datum.find { |data| data['call.method'] == 'call' }
72
- data_name = stack_datum.find { |data| !!data['name'] }
72
+ # data_name = stack_datum.find { |data| !!data['name'] }
73
73
 
74
74
  # See if we can recover a transaction id out of this hot mess.
75
75
  data_trx_ix = stack_datum.find { |data| !!data['trx_ix'] }
@@ -4,4 +4,4 @@ module Radiator
4
4
  :follow_api
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -16,4 +16,4 @@ module Radiator
16
16
  :market_history_api
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -20,7 +20,7 @@ module Radiator
20
20
  # @option options [String] :parent_permlink (automatic) Parent permlink of the post, defaults to first tag.
21
21
  # @option options [String] :parent_author (optional) Parent author of the post (only used if reply).
22
22
  # @option options [String] :max_accepted_payout (1000000.000 SBD) Maximum accepted payout, set to '0.000 SBD' to deline payout
23
- # @option options [Integer] :percent_steem_dollars (5000) Percent STEEM Dollars is used to set 50/50 or 100% STEEM Power
23
+ # @option options [Integer] :percent_hbd (5000) Percent HBD is used to set 50/50 or 100% HIVE Power
24
24
  # @option options [Integer] :allow_votes (true) Allow votes for this post.
25
25
  # @option options [Integer] :allow_curation_rewards (true) Allow curation rewards for this post.
26
26
  def post(options = {})
@@ -34,7 +34,7 @@ module Radiator
34
34
  body = options[:body]
35
35
  parent_author = options[:parent_author] || ''
36
36
  max_accepted_payout = options[:max_accepted_payout] || default_max_acepted_payout
37
- percent_steem_dollars = options[:percent_steem_dollars]
37
+ percent_hbd = options[:percent_hbd]
38
38
  allow_votes = options[:allow_votes] || true
39
39
  allow_curation_rewards = options[:allow_curation_rewards] || true
40
40
  self_vote = options[:self_vote]
@@ -60,13 +60,13 @@ module Radiator
60
60
 
61
61
  if (!!max_accepted_payout &&
62
62
  max_accepted_payout != default_max_acepted_payout
63
- ) || !!percent_steem_dollars || !allow_votes || !allow_curation_rewards
63
+ ) || !!percent_hbd || !allow_votes || !allow_curation_rewards
64
64
  @operations << {
65
65
  type: :comment_options,
66
66
  author: account_name,
67
67
  permlink: permlink,
68
68
  max_accepted_payout: max_accepted_payout,
69
- percent_steem_dollars: percent_steem_dollars,
69
+ percent_hbd: percent_hbd,
70
70
  allow_votes: allow_votes,
71
71
  allow_curation_rewards: allow_curation_rewards,
72
72
  extensions: []
@@ -5,11 +5,12 @@ module Radiator
5
5
  include Utils
6
6
 
7
7
  def initialize(options = {})
8
+ chain = (options.delete(:chain) || 'hive').to_sym
8
9
  opt = options.dup
9
10
  @type = opt.delete(:type)
10
11
 
11
12
  opt.each do |k, v|
12
- instance_variable_set("@#{k}", type(@type, k, v))
13
+ instance_variable_set("@#{k}", type(chain, @type, k, v))
13
14
  end
14
15
 
15
16
  @use_condenser_namespace = if options.keys.include? :use_condenser_namespace
@@ -61,7 +62,7 @@ module Radiator
61
62
 
62
63
  params[p] = case v
63
64
  when Radiator::Type::Beneficiaries then [[0, v.to_h]]
64
- when Radiator::Type::Amount
65
+ when Hive::Type::Amount, Steem::Type::Amount
65
66
  if use_condenser_namespace?
66
67
  v.to_s
67
68
  else
@@ -4,18 +4,18 @@ module Radiator
4
4
  module OperationTypes
5
5
  TYPES = {
6
6
  transfer: {
7
- amount: Type::Amount
7
+ amount: Hive::Type::Amount
8
8
  },
9
9
  transfer_to_vesting: {
10
- amount: Type::Amount
10
+ amount: Hive::Type::Amount
11
11
  },
12
12
  withdraw_vesting: {
13
- vesting_shares: Type::Amount
13
+ vesting_shares: Hive::Type::Amount
14
14
  },
15
15
  limit_order_create: {
16
16
  orderid: Type::Uint32,
17
- amount_to_sell: Type::Amount,
18
- min_to_receive: Type::Amount,
17
+ amount_to_sell: Hive::Type::Amount,
18
+ min_to_receive: Hive::Type::Amount,
19
19
  expiration: Type::PointInTime
20
20
  },
21
21
  limit_order_cancel: {
@@ -26,10 +26,10 @@ module Radiator
26
26
  },
27
27
  convert: {
28
28
  requestid: Type::Uint32,
29
- amount: Type::Amount
29
+ amount: Hive::Type::Amount
30
30
  },
31
31
  account_create: {
32
- fee: Type::Amount,
32
+ fee: Hive::Type::Amount,
33
33
  owner: Type::Permission,
34
34
  active: Type::Permission,
35
35
  posting: Type::Permission,
@@ -51,7 +51,7 @@ module Radiator
51
51
  id: Type::Uint16
52
52
  },
53
53
  comment_options: {
54
- max_accepted_payout: Type::Amount,
54
+ max_accepted_payout: Hive::Type::Amount,
55
55
  allow_replies: Type::Future
56
56
  },
57
57
  set_withdraw_vesting_route: {
@@ -59,7 +59,7 @@ module Radiator
59
59
  },
60
60
  limit_order_create2: {
61
61
  orderid: Type::Uint32,
62
- amount_to_sell: Type::Amount,
62
+ amount_to_sell: Hive::Type::Amount,
63
63
  exchange_rate: Type::Price,
64
64
  expiration: Type::PointInTime
65
65
  },
@@ -71,10 +71,12 @@ module Radiator
71
71
  recent_owner_Permission: Type::Permission
72
72
  },
73
73
  escrow_transfer: {
74
- sbd_amount: Type::Amount,
75
- steem_amount: Type::Amount,
74
+ sbd_amount: Steem::Type::Amount,
75
+ hbd_amount: Hive::Type::Amount,
76
+ steem_amount: Steem::Type::Amount,
77
+ hive_amount: Hive::Type::Amount,
76
78
  escrow_id: Type::Uint32,
77
- fee: Type::Amount,
79
+ fee: Hive::Type::Amount,
78
80
  ratification_deadline: Type::PointInTime,
79
81
  escrow_expiration: Type::PointInTime
80
82
  },
@@ -83,40 +85,46 @@ module Radiator
83
85
  },
84
86
  escrow_release: {
85
87
  escrow_id: Type::Uint32,
86
- sbd_amount: Type::Amount,
87
- steem_amount: Type::Amount
88
+ sbd_amount: Steem::Type::Amount,
89
+ hbd_amount: Hive::Type::Amount,
90
+ steem_amount: Steem::Type::Amount,
91
+ hive_amount: Hive::Type::Amount
88
92
  },
89
93
  escrow_approve: {
90
94
  escrow_id: Type::Uint32
91
95
  },
92
96
  transfer_to_savings: {
93
- amount: Type::Amount
97
+ amount: Hive::Type::Amount
94
98
  },
95
99
  transfer_from_savings: {
96
100
  request_id: Type::Uint32,
97
- amount: Type::Amount
101
+ amount: Hive::Type::Amount
98
102
  },
99
103
  cancel_transfer_from_savings: {
100
104
  request_id: Type::Uint32
101
105
  },
102
106
  reset_account: {
103
- new_owner_permission: Type::Amount
107
+ new_owner_permission: Hive::Type::Amount
104
108
  },
105
109
  set_reset_account: {
106
- reward_steem: Type::Amount,
107
- reward_sbd: Type::Amount,
108
- reward_vests: Type::Amount
110
+ reward_steem: Steem::Type::Amount,
111
+ reward_hive: Hive::Type::Amount,
112
+ reward_sbd: Steem::Type::Amount,
113
+ reward_hbd: Hive::Type::Amount,
114
+ reward_vests: Hive::Type::Amount
109
115
  },
110
116
  claim_reward_balance: {
111
- reward_steem: Type::Amount,
112
- reward_sbd: Type::Amount,
113
- reward_vests: Type::Amount
117
+ reward_steem: Steem::Type::Amount,
118
+ reward_hive: Hive::Type::Amount,
119
+ reward_sbd: Steem::Type::Amount,
120
+ reward_hbd: Hive::Type::Amount,
121
+ reward_vests: Hive::Type::Amount
114
122
  },
115
123
  delegate_vesting_shares: {
116
- vesting_shares: Type::Amount
124
+ vesting_shares: Hive::Type::Amount
117
125
  },
118
126
  claim_account: {
119
- fee: Type::Amount
127
+ fee: Hive::Type::Amount
120
128
  },
121
129
  witness_update: {
122
130
  block_signing_key: Type::PublicKey,
@@ -127,13 +135,21 @@ module Radiator
127
135
  }
128
136
  }
129
137
 
130
- def type(key, param, value)
138
+ def type(chain, key, param, value)
131
139
  return if value.nil?
132
140
 
133
141
  t = TYPES[key] or return value
134
142
  p = t[param] or return value
135
143
 
136
- p.new(value)
144
+ if p == Hive::Type::Amount
145
+ case chain
146
+ when :steem then Steem::Type::Amount.new(value)
147
+ else
148
+ p.new(value)
149
+ end
150
+ else
151
+ p.new(value)
152
+ end
137
153
  end
138
154
  end
139
155
  end
@@ -75,7 +75,7 @@ module Radiator
75
75
  http.keep_alive = 30
76
76
  http.idle_timeout = 10
77
77
  http.max_requests = @max_requests
78
- http.retry_change_requests = true
78
+ http.retry_change_requests = true if defined? http.retry_change_requests
79
79
  http.reuse_ssl_sessions = @reuse_ssl_sessions
80
80
  end
81
81
  else
@@ -258,7 +258,7 @@ module Radiator
258
258
  break if stop?
259
259
 
260
260
  catch :sequence do; begin
261
- head_block = api.get_dynamic_global_properties do |properties, error|
261
+ head_block = database_api.get_dynamic_global_properties do |properties, error|
262
262
  if !!error
263
263
  standby "Node responded with: #{error.message || 'unknown error'}, retrying ...", {
264
264
  error: error,
@@ -268,7 +268,7 @@ module Radiator
268
268
 
269
269
  break if stop?
270
270
 
271
- if properties.head_block_number.nil?
271
+ if properties.nil? || properties.head_block_number.nil?
272
272
  # This can happen if a reverse proxy is acting up.
273
273
  standby "Bad block sequence after height: #{latest_block_number}", {
274
274
  and: {throw: :sequence}
@@ -281,7 +281,7 @@ module Radiator
281
281
  else; raise StreamError, '"mode" has to be "head" or "irreversible"'
282
282
  end
283
283
  end
284
-
284
+
285
285
  if head_block == latest_block_number
286
286
  # This can happen when there's a delay in block production.
287
287
 
@@ -332,7 +332,7 @@ module Radiator
332
332
  [block_api, {block_num: n}]
333
333
  end
334
334
 
335
- scoped_api.get_block(n) do |current_block, error|
335
+ scoped_api.get_block(block_options) do |current_block, error|
336
336
  if !!error
337
337
  if error.message == 'Unable to acquire database lock'
338
338
  start = n
@@ -346,7 +346,11 @@ module Radiator
346
346
  and: {throw: :sequence}
347
347
  }
348
348
  end
349
- elsif current_block.nil?
349
+ end
350
+
351
+ current_block = current_block.block unless use_condenser_namespace?
352
+
353
+ if current_block.nil?
350
354
  standby "Node responded with: empty block, retrying ...", {
351
355
  and: {throw: :sequence}
352
356
  }
@@ -390,6 +394,7 @@ module Radiator
390
394
 
391
395
  @api = nil
392
396
  @block_api = nil
397
+ @database_api = nil if @api.nil? || @block_api.nil?
393
398
  GC.start
394
399
  end
395
400
 
@@ -435,6 +440,14 @@ module Radiator
435
440
  else; nil
436
441
  end
437
442
  end
443
+
444
+ def database_api
445
+ @database_api ||= case @chain
446
+ when :steem then Steem::DatabaseApi.new(url: @api.send(:uri).to_s)
447
+ when :hive then Hive::DatabaseApi.new(url: @api.send(:uri).to_s)
448
+ else; api
449
+ end
450
+ end
438
451
  private
439
452
  def method_missing(m, *args, &block)
440
453
  super unless respond_to_missing?(m)
@@ -445,11 +458,11 @@ module Radiator
445
458
  break if stop?
446
459
 
447
460
  value = if (n = method_params(m)).nil?
448
- key_value = api.get_dynamic_global_properties.result[m]
461
+ key_value = database_api.get_dynamic_global_properties.result[m]
449
462
  else
450
463
  key = n.keys.first
451
464
  if !!n[key]
452
- r = api.get_dynamic_global_properties.result
465
+ r = database_api.get_dynamic_global_properties.result
453
466
  key_value = param = r[n[key]]
454
467
  result = nil
455
468
  loop do
@@ -466,7 +479,7 @@ module Radiator
466
479
  reset_timeout
467
480
  result
468
481
  else
469
- key_value = api.get_dynamic_global_properties.result[key]
482
+ key_value = database_api.get_dynamic_global_properties.result[key]
470
483
  end
471
484
  end
472
485
  unless @latest_values.include? key_value