radiator 0.4.6 → 0.4.8
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 +5 -5
- data/README.md +27 -12
- data/Rakefile +53 -23
- data/lib/radiator.rb +3 -1
- data/lib/radiator/api.rb +111 -16
- data/lib/radiator/bridge.rb +34 -0
- data/lib/radiator/broadcast_operations.json +7 -7
- data/lib/radiator/chain.rb +1 -1
- data/lib/radiator/chain_config.rb +9 -2
- data/lib/radiator/database_api.rb +1 -1
- data/lib/radiator/error_parser.rb +1 -1
- data/lib/radiator/follow_api.rb +1 -1
- data/lib/radiator/market_history_api.rb +1 -1
- data/lib/radiator/mixins/acts_as_poster.rb +4 -4
- data/lib/radiator/operation.rb +3 -2
- data/lib/radiator/operation_types.rb +43 -27
- data/lib/radiator/ssc/base_steem_smart_contract_rpc.rb +1 -1
- data/lib/radiator/stream.rb +21 -8
- data/lib/radiator/transaction.rb +43 -3
- data/lib/radiator/type/amount.rb +8 -50
- data/lib/radiator/type/beneficiaries.rb +8 -1
- data/lib/radiator/type/price.rb +2 -2
- data/lib/radiator/version.rb +1 -1
- data/radiator.gemspec +17 -13
- data/test/fixtures/empty.json +1 -0
- data/test/fixtures/error.json +29 -0
- data/test/fixtures/follow_api_get_followers.json +1 -0
- data/test/fixtures/get_account.json +165 -0
- data/test/fixtures/get_account_count.json +1 -0
- data/test/fixtures/get_account_references.json +1 -0
- data/test/fixtures/get_block.json +193 -0
- data/test/fixtures/get_dynamic_global_properties.json +32 -0
- data/test/fixtures/get_feed_history.json +684 -0
- data/test/fixtures/get_hardfork_version.json +1 -0
- data/test/fixtures/get_key_references.json +14 -0
- data/test/fixtures/get_stats_for_time.json +57 -0
- data/test/fixtures/get_vesting_delegation.json +936 -0
- data/test/fixtures/golos_get_dynamic_global_properties.json +32 -0
- data/test/fixtures/market_history_api_get_market_history_buckets.json +1 -0
- data/test/fixtures/market_history_api_get_order_book.json +109 -0
- data/test/fixtures/market_history_api_get_recent_trades.json +55 -0
- data/test/fixtures/market_history_api_get_ticker.json +11 -0
- data/test/fixtures/market_history_api_get_volume.json +1 -0
- data/test/fixtures/null.json +1 -0
- data/test/fixtures/vcr_cassettes/account_by_key_api_all_methods.yml +1465 -0
- data/test/fixtures/vcr_cassettes/account_by_key_api_jsonrpc.yml +199 -0
- data/test/fixtures/vcr_cassettes/api_all_methods.yml +13802 -0
- data/test/fixtures/vcr_cassettes/api_jsonrpc.yml +53 -0
- data/test/fixtures/vcr_cassettes/base_per_debt.yml +11068 -0
- data/test/fixtures/vcr_cassettes/base_per_mvest.yml +6024 -0
- data/test/fixtures/vcr_cassettes/block_time.yml +5368 -0
- data/test/fixtures/vcr_cassettes/broadcast_transaction.yml +1723 -0
- data/test/fixtures/vcr_cassettes/chain_stats_api_jsonrpc.yml +51 -0
- data/test/fixtures/vcr_cassettes/condenser_all_all_methods.yml +13770 -0
- data/test/fixtures/vcr_cassettes/condenser_api_jsonrpc.yml +103 -0
- data/test/fixtures/vcr_cassettes/expiration_initialize.yml +16108 -0
- data/test/fixtures/vcr_cassettes/find_account.yml +5732 -0
- data/test/fixtures/vcr_cassettes/find_block.yml +5322 -0
- data/test/fixtures/vcr_cassettes/find_comment.yml +16386 -0
- data/test/fixtures/vcr_cassettes/follow_api_jsonrpc.yml +99 -0
- data/test/fixtures/vcr_cassettes/get_account_count.yml +783 -0
- data/test/fixtures/vcr_cassettes/get_account_references.yml +773 -0
- data/test/fixtures/vcr_cassettes/get_accounts.yml +918 -0
- data/test/fixtures/vcr_cassettes/get_accounts_no_argument.yml +773 -0
- data/test/fixtures/vcr_cassettes/get_dynamic_global_properties.yml +893 -0
- data/test/fixtures/vcr_cassettes/get_feed_history.yml +1432 -0
- data/test/fixtures/vcr_cassettes/get_hardfork_version.yml +835 -0
- data/test/fixtures/vcr_cassettes/get_key_references.yml +1571 -0
- data/test/fixtures/vcr_cassettes/get_market_history.yml +1563 -0
- data/test/fixtures/vcr_cassettes/get_market_history_buckets.yml +1665 -0
- data/test/fixtures/vcr_cassettes/get_order_book.yml +1459 -0
- data/test/fixtures/vcr_cassettes/get_recent_trades.yml +1459 -0
- data/test/fixtures/vcr_cassettes/get_ticker.yml +1563 -0
- data/test/fixtures/vcr_cassettes/get_trade_history.yml +1459 -0
- data/test/fixtures/vcr_cassettes/get_vesting_delegations.yml +731 -0
- data/test/fixtures/vcr_cassettes/get_volume.yml +1561 -0
- data/test/fixtures/vcr_cassettes/get_witness_by_account.yml +835 -0
- data/test/fixtures/vcr_cassettes/look_up_witnesses.yml +831 -0
- data/test/fixtures/vcr_cassettes/market_history_api_all_methods.yml +10191 -0
- data/test/fixtures/vcr_cassettes/market_history_api_jsonrpc.yml +51 -0
- data/test/fixtures/vcr_cassettes/network_broadcast_api_all_methods.yml +2455 -0
- data/test/fixtures/vcr_cassettes/network_broadcast_api_jsonrpc.yml +51 -0
- data/test/fixtures/vcr_cassettes/properties.yml +5551 -0
- data/test/fixtures/vcr_cassettes/recover_transaction.yml +1815 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_block_info.yml +90 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_block_info_invalid.yml +88 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_latest_block_info.yml +90 -0
- data/test/fixtures/vcr_cassettes/ssc_blockchain_transaction_info.yml +90 -0
- data/test/fixtures/vcr_cassettes/ssc_contracts_contract.yml +364 -0
- data/test/fixtures/vcr_cassettes/ssc_contracts_find.yml +89 -0
- data/test/fixtures/vcr_cassettes/ssc_contracts_find_one.yml +87 -0
- data/test/fixtures/vcr_cassettes/stream_jsonrpc.yml +27502 -0
- data/test/fixtures/vcr_cassettes/tag_api_jsonrpc.yml +155 -0
- data/test/fixtures/vcr_cassettes/transaction_expiration_initialize_nil.yml +17597 -0
- data/test/fixtures/vcr_cassettes/transaction_jsonrpc.yml +61 -0
- data/test/fixtures/vcr_cassettes/unknown_chain_id.yml +13038 -0
- data/test/fixtures/vcr_cassettes/valid_chains.yml +11450 -0
- data/test/radiator/account_by_key_api_test.rb +46 -0
- data/test/radiator/api_test.rb +135 -0
- data/test/radiator/chain_stats_api_test.rb +49 -0
- data/test/radiator/chain_test.rb +153 -0
- data/test/radiator/condenser_api_test.rb +48 -0
- data/test/radiator/follow_api_test.rb +48 -0
- data/test/radiator/market_history_api_test.rb +100 -0
- data/test/radiator/network_broadcast_api_test.rb +48 -0
- data/test/radiator/operation_test.rb +116 -0
- data/test/radiator/ssc/blockchain_test.rb +58 -0
- data/test/radiator/ssc/contracts_test.rb +65 -0
- data/test/radiator/stream_test.rb +48 -0
- data/test/radiator/tag_api_test.rb +40 -0
- data/test/radiator/transaction_test.rb +755 -0
- data/test/test_helper.rb +66 -0
- metadata +187 -79
- data/.codeclimate.yml +0 -19
- data/.gitignore +0 -52
- data/.travis.yml +0 -23
- data/gource.sh +0 -8
- data/images/Anthony Martin.png +0 -0
- data/images/Marvin Hofmann.jpg +0 -0
- data/images/Marvin Hofmann.png +0 -0
- 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
|
-
"
|
|
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
|
-
"
|
|
282
|
-
"
|
|
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
|
-
"
|
|
311
|
-
"
|
|
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
|
-
"
|
|
403
|
-
"
|
|
402
|
+
"reward_hive",
|
|
403
|
+
"reward_hbd",
|
|
404
404
|
"reward_vests"
|
|
405
405
|
]
|
|
406
406
|
},
|
data/lib/radiator/chain.rb
CHANGED
|
@@ -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
|
|
@@ -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'] }
|
data/lib/radiator/follow_api.rb
CHANGED
|
@@ -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] :
|
|
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
|
-
|
|
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
|
-
) || !!
|
|
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
|
-
|
|
69
|
+
percent_hbd: percent_hbd,
|
|
70
70
|
allow_votes: allow_votes,
|
|
71
71
|
allow_curation_rewards: allow_curation_rewards,
|
|
72
72
|
extensions: []
|
data/lib/radiator/operation.rb
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
-
|
|
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
|
-
|
|
113
|
-
|
|
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
|
|
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
|
data/lib/radiator/stream.rb
CHANGED
|
@@ -258,7 +258,7 @@ module Radiator
|
|
|
258
258
|
break if stop?
|
|
259
259
|
|
|
260
260
|
catch :sequence do; begin
|
|
261
|
-
head_block =
|
|
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(
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|