hive-ruby 1.0.0.pre.1 → 1.0.2
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/.gitignore +1 -1
- data/.gitlab-ci.yml +17 -0
- data/Rakefile +9 -9
- data/assets/logo-128.png +0 -0
- data/assets/logo.png +0 -0
- data/assets/logo.xcf +0 -0
- data/hive-ruby.gemspec +5 -5
- data/lib/hive.rb +4 -0
- data/lib/hive/api.rb +3 -1
- data/lib/hive/base_error.rb +19 -3
- data/lib/hive/block_api.rb +2 -2
- data/lib/hive/broadcast.rb +148 -29
- data/lib/hive/fallback.rb +35 -9
- data/lib/hive/jsonrpc.rb +2 -2
- data/lib/hive/marshal.rb +11 -8
- data/lib/hive/mixins/serializable.rb +1 -1
- data/lib/hive/operation.rb +5 -1
- data/lib/hive/operation/account_update2.rb +4 -0
- data/lib/hive/operation/claim_reward_balance.rb +2 -2
- data/lib/hive/operation/comment_options.rb +1 -1
- data/lib/hive/operation/create_proposal.rb +9 -0
- data/lib/hive/operation/escrow_release.rb +2 -2
- data/lib/hive/operation/escrow_transfer.rb +2 -2
- data/lib/hive/operation/remove_proposal.rb +4 -0
- data/lib/hive/operation/update_proposal_votes.rb +5 -0
- data/lib/hive/rpc/http_client.rb +30 -10
- data/lib/hive/rpc/thread_safe_http_client.rb +13 -6
- data/lib/hive/stream.rb +1 -1
- data/lib/hive/version.rb +1 -1
- metadata +38 -32
- data/Gemfile.lock +0 -91
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0532e4cf00c66e983cec921fd1ef3d193df1d61c5c317254f1876c3741299c4c
|
|
4
|
+
data.tar.gz: f14bf0b18bdd1ed9926708c89f9fe0f9a3b83cfa81dd310ac3673b0f49d3b69f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7204cf39c276304f1ee0c8fb0ed125fc82a4ddcb905841db870bc1ea39e7a10f5ac0da18fd2b49c5a8c4fa16ed0bc154bb1744fcaeb6c292f423a2bdf024bfc
|
|
7
|
+
data.tar.gz: d7189046c313b6d7eeeb39b81bb4ad7472bc4a80093d27a7c1a4aef2e53fd7ad07bfedda690b11638bdc93368914c16a29f9045f90f3b47d510a979da1f31b04
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
image: ruby:2.6.1-alpine
|
|
2
|
+
|
|
3
|
+
pages:
|
|
4
|
+
script:
|
|
5
|
+
- apk add --update --no-cache build-base libxml2-dev libxslt-dev libstdc++ tzdata mariadb-dev nodejs ca-certificates yarn
|
|
6
|
+
- bundle install --path vendor
|
|
7
|
+
- bundle exec yard
|
|
8
|
+
- rm -rf public
|
|
9
|
+
- mv doc public
|
|
10
|
+
artifacts:
|
|
11
|
+
paths:
|
|
12
|
+
- public
|
|
13
|
+
cache:
|
|
14
|
+
paths:
|
|
15
|
+
- vendor
|
|
16
|
+
only:
|
|
17
|
+
- master
|
data/Rakefile
CHANGED
|
@@ -112,20 +112,20 @@ namespace :test do
|
|
|
112
112
|
[k, v] if keys.include? k.to_sym
|
|
113
113
|
end.compact.to_h
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
base =
|
|
115
|
+
hbd_exchange_rate = witness[:hbd_exchange_rate] || witness[:hbd_exchange_rate]
|
|
116
|
+
base = hbd_exchange_rate[:base].to_f
|
|
117
117
|
|
|
118
|
-
if (quote =
|
|
118
|
+
if (quote = hbd_exchange_rate[:quote].to_f) > 0
|
|
119
119
|
rate = (base / quote).round(3)
|
|
120
|
-
witnesses[witness.owner][:
|
|
120
|
+
witnesses[witness.owner][:hbd_exchange_rate] = rate
|
|
121
121
|
else
|
|
122
|
-
witnesses[witness.owner][:
|
|
122
|
+
witnesses[witness.owner][:hbd_exchange_rate] = nil
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
witnesses[witness.owner][:
|
|
125
|
+
last_hbd_exchange_update = witness[:last_hbd_exchange_update] || witness[:last_hbd_exchange_update]
|
|
126
|
+
last_hbd_exchange_update = Time.parse(last_hbd_exchange_update + 'Z')
|
|
127
|
+
last_hbd_exchange_elapsed = '%.2f hours ago' % ((Time.now.utc - last_hbd_exchange_update) / 60)
|
|
128
|
+
witnesses[witness.owner][:last_hbd_exchange_elapsed] = last_hbd_exchange_elapsed
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
end
|
data/assets/logo-128.png
ADDED
|
Binary file
|
data/assets/logo.png
ADDED
|
Binary file
|
data/assets/logo.xcf
ADDED
|
Binary file
|
data/hive-ruby.gemspec
CHANGED
|
@@ -17,14 +17,14 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
|
|
18
18
|
spec.require_paths = ['lib']
|
|
19
19
|
|
|
20
|
-
spec.add_development_dependency 'bundler', '~> 1
|
|
20
|
+
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
|
21
21
|
spec.add_development_dependency 'rake', '~> 13.0.1', '>= 12.3.0'
|
|
22
|
-
spec.add_development_dependency 'minitest', '~> 5.
|
|
22
|
+
spec.add_development_dependency 'minitest', '~> 5.14', '>= 5.10.3'
|
|
23
23
|
spec.add_development_dependency 'minitest-line', '~> 0.6', '>= 0.6.4'
|
|
24
24
|
spec.add_development_dependency 'minitest-proveit', '~> 1.0', '>= 1.0.0'
|
|
25
25
|
spec.add_development_dependency 'webmock', '~> 3.3', '>= 3.3.0'
|
|
26
26
|
spec.add_development_dependency 'simplecov', '~> 0.15', '>= 0.15.1'
|
|
27
|
-
spec.add_development_dependency 'vcr', '~>
|
|
27
|
+
spec.add_development_dependency 'vcr', '~> 6.0', '>= 4.0.0'
|
|
28
28
|
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.12'
|
|
29
29
|
spec.add_development_dependency 'pry', '~> 0.11', '>= 0.11.3'
|
|
30
30
|
spec.add_development_dependency 'awesome_print', '~> 1.8', '>= 1.8.0'
|
|
@@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
|
|
33
33
|
spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
|
|
34
34
|
spec.add_dependency 'logging', '~> 2.2', '>= 2.2.0'
|
|
35
|
-
spec.add_dependency 'hashie', '~>
|
|
36
|
-
spec.add_dependency 'bitcoin-ruby', '~> 0.0', '
|
|
35
|
+
spec.add_dependency 'hashie', '~> 4.1', '>= 3.5.7'
|
|
36
|
+
spec.add_dependency 'bitcoin-ruby', '~> 0.0', '0.0.20'
|
|
37
37
|
spec.add_dependency 'ffi', '~> 1.9', '>= 1.9.23'
|
|
38
38
|
spec.add_dependency 'bindata', '~> 2.4', '>= 2.4.4'
|
|
39
39
|
spec.add_dependency 'base58', '~> 0.2', '>= 0.2.3'
|
data/lib/hive.rb
CHANGED
|
@@ -16,6 +16,7 @@ require 'hive/operation'
|
|
|
16
16
|
require 'hive/operation/account_create.rb'
|
|
17
17
|
require 'hive/operation/account_create_with_delegation.rb'
|
|
18
18
|
require 'hive/operation/account_update.rb'
|
|
19
|
+
require 'hive/operation/account_update2.rb'
|
|
19
20
|
require 'hive/operation/account_witness_proxy.rb'
|
|
20
21
|
require 'hive/operation/account_witness_vote.rb'
|
|
21
22
|
require 'hive/operation/cancel_transfer_from_savings.rb'
|
|
@@ -27,6 +28,7 @@ require 'hive/operation/comment.rb'
|
|
|
27
28
|
require 'hive/operation/comment_options.rb'
|
|
28
29
|
require 'hive/operation/convert.rb'
|
|
29
30
|
require 'hive/operation/create_claimed_account.rb'
|
|
31
|
+
require 'hive/operation/create_proposal.rb'
|
|
30
32
|
require 'hive/operation/custom.rb'
|
|
31
33
|
require 'hive/operation/custom_binary.rb'
|
|
32
34
|
require 'hive/operation/custom_json.rb'
|
|
@@ -43,6 +45,7 @@ require 'hive/operation/limit_order_create.rb'
|
|
|
43
45
|
require 'hive/operation/limit_order_create2.rb'
|
|
44
46
|
require 'hive/operation/prove_authority.rb'
|
|
45
47
|
require 'hive/operation/recover_account.rb'
|
|
48
|
+
require 'hive/operation/remove_proposal.rb'
|
|
46
49
|
require 'hive/operation/report_over_production.rb'
|
|
47
50
|
require 'hive/operation/request_account_recovery.rb'
|
|
48
51
|
require 'hive/operation/reset_account.rb'
|
|
@@ -52,6 +55,7 @@ require 'hive/operation/transfer.rb'
|
|
|
52
55
|
require 'hive/operation/transfer_from_savings.rb'
|
|
53
56
|
require 'hive/operation/transfer_to_savings.rb'
|
|
54
57
|
require 'hive/operation/transfer_to_vesting.rb'
|
|
58
|
+
require 'hive/operation/update_proposal_votes.rb'
|
|
55
59
|
require 'hive/operation/vote.rb'
|
|
56
60
|
require 'hive/operation/withdraw_vesting.rb'
|
|
57
61
|
require 'hive/operation/witness_update.rb'
|
data/lib/hive/api.rb
CHANGED
|
@@ -118,7 +118,9 @@ module Hive
|
|
|
118
118
|
|
|
119
119
|
if Jsonrpc::UNLISTED_APIS.include? @api_name
|
|
120
120
|
@methods ||= {}
|
|
121
|
-
@methods[@api_name] ||=
|
|
121
|
+
@methods[@api_name] ||= []
|
|
122
|
+
@methods[@api_name] += Fallback::API_METHODS[@api_name]
|
|
123
|
+
@methods[@api_name] = @methods[@api_name].uniq
|
|
122
124
|
end
|
|
123
125
|
|
|
124
126
|
unless !!@methods[@api_name]
|
data/lib/hive/base_error.rb
CHANGED
|
@@ -19,17 +19,21 @@ module Hive
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
if error.message.include? 'Internal Error'
|
|
22
|
-
raise Hive::
|
|
22
|
+
raise Hive::RemoteInternalError, error.message, build_backtrace(error)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
if error.message.include? 'Server error'
|
|
26
|
-
raise Hive::
|
|
26
|
+
raise Hive::RemoteServerError, error.message, build_backtrace(error)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
if error.message.include?
|
|
29
|
+
if error.message.include?('plugin not enabled') || error.message.include?('Could not find API')
|
|
30
30
|
raise Hive::PluginNotEnabledError, error.message, build_backtrace(error)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
if error.message.include? 'Supported by hivemind'
|
|
34
|
+
raise Hive::MethodNotEnabledError, error.message, build_backtrace(error)
|
|
35
|
+
end
|
|
36
|
+
|
|
33
37
|
if error.message.include? 'argument'
|
|
34
38
|
raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
|
|
35
39
|
end
|
|
@@ -74,6 +78,10 @@ module Hive
|
|
|
74
78
|
raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
|
|
75
79
|
end
|
|
76
80
|
|
|
81
|
+
if error.message.include? 'Invalid parameter'
|
|
82
|
+
raise Hive::ArgumentError, "#{context}: #{error.message}", build_backtrace(error)
|
|
83
|
+
end
|
|
84
|
+
|
|
77
85
|
if error.message.include? 'blk->transactions.size() > itr->trx_in_block'
|
|
78
86
|
raise Hive::VirtualOperationsNotAllowedError, "#{context}: #{error.message}", build_backtrace(error)
|
|
79
87
|
end
|
|
@@ -122,6 +130,10 @@ module Hive
|
|
|
122
130
|
raise Hive::UpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error)
|
|
123
131
|
end
|
|
124
132
|
|
|
133
|
+
if error.message.include? 'Request Timeout'
|
|
134
|
+
raise Hive::RequestTimeoutUpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error)
|
|
135
|
+
end
|
|
136
|
+
|
|
125
137
|
if error.message.include? 'Bad or missing upstream response'
|
|
126
138
|
raise Hive::BadOrMissingUpstreamResponseError, "#{context}: #{error.message}", build_backtrace(error)
|
|
127
139
|
end
|
|
@@ -202,9 +214,13 @@ module Hive
|
|
|
202
214
|
class IncorrectRequestIdError < BaseError; end
|
|
203
215
|
class IncorrectResponseIdError < BaseError; end
|
|
204
216
|
class RemoteNodeError < BaseError; end
|
|
217
|
+
class RemoteInternalError < BaseError; end
|
|
218
|
+
class RemoteServerError < BaseError; end
|
|
205
219
|
class UpstreamResponseError < RemoteNodeError; end
|
|
206
220
|
class RemoteDatabaseLockError < UpstreamResponseError; end
|
|
207
221
|
class PluginNotEnabledError < UpstreamResponseError; end
|
|
222
|
+
class MethodNotEnabledError < UpstreamResponseError; end
|
|
223
|
+
class RequestTimeoutUpstreamResponseError < UpstreamResponseError; end
|
|
208
224
|
class BadOrMissingUpstreamResponseError < UpstreamResponseError; end
|
|
209
225
|
class TransactionIndexDisabledError < BaseError; end
|
|
210
226
|
class NotAppBaseError < BaseError; end
|
data/lib/hive/block_api.rb
CHANGED
|
@@ -52,7 +52,7 @@ module Hive
|
|
|
52
52
|
|
|
53
53
|
if !!block
|
|
54
54
|
index = 0
|
|
55
|
-
@rpc_client.rpc_batch_execute(request_object: request_object) do |result, error, id|
|
|
55
|
+
@rpc_client.rpc_batch_execute(api_name: self.class.api_name, request_object: request_object) do |result, error, id|
|
|
56
56
|
block_num = sub_range.to_a[index]
|
|
57
57
|
index = index + 1
|
|
58
58
|
|
|
@@ -66,7 +66,7 @@ module Hive
|
|
|
66
66
|
else
|
|
67
67
|
blocks = []
|
|
68
68
|
|
|
69
|
-
@rpc_client.rpc_batch_execute(request_object: request_object) do |result, error, id|
|
|
69
|
+
@rpc_client.rpc_batch_execute(api_name: self.class.api_name, request_object: request_object) do |result, error, id|
|
|
70
70
|
blocks << result
|
|
71
71
|
end
|
|
72
72
|
end
|
data/lib/hive/broadcast.rb
CHANGED
|
@@ -137,7 +137,7 @@ module Hive
|
|
|
137
137
|
# * :parent_permlink (String) (automatic) Parent permlink of the content, defaults to first tag.
|
|
138
138
|
# * :parent_author (String) (optional) Parent author of the content (only used if reply).
|
|
139
139
|
# * :max_accepted_payout (String) (1000000.000 HBD) Maximum accepted payout, set to '0.000 HBD' to deline payout
|
|
140
|
-
# * :
|
|
140
|
+
# * :percent_hbd (Numeric) (5000) Percent HIVE Dollars is used to set 50/50 or 100% HIVE Power
|
|
141
141
|
# * :allow_votes (Numeric) (true) Allow votes for this content.
|
|
142
142
|
# * :allow_curation_rewards (Numeric) (true) Allow curation rewards for this content.
|
|
143
143
|
# * :beneficiaries (Array<Hash>) Sets the beneficiaries of this content.
|
|
@@ -196,7 +196,7 @@ module Hive
|
|
|
196
196
|
author: params[:author],
|
|
197
197
|
permlink: params[:permlink],
|
|
198
198
|
max_accepted_payout: max_accepted_payout,
|
|
199
|
-
|
|
199
|
+
percent_hbd: params[:percent_hbd] || 10000,
|
|
200
200
|
# allow_replies: allow_replies,
|
|
201
201
|
allow_votes: allow_votes,
|
|
202
202
|
allow_curation_rewards: allow_curation_rewards,
|
|
@@ -646,7 +646,7 @@ module Hive
|
|
|
646
646
|
# props: {
|
|
647
647
|
# account_creation_fee: '0.000 HIVE',
|
|
648
648
|
# maximum_block_size: 131072,
|
|
649
|
-
#
|
|
649
|
+
# hbd_interest_rate:1000
|
|
650
650
|
# },
|
|
651
651
|
# fee: '0.000 HIVE',
|
|
652
652
|
# }
|
|
@@ -688,10 +688,10 @@ module Hive
|
|
|
688
688
|
# props: {
|
|
689
689
|
# account_creation_fee: '0.000 HIVE',
|
|
690
690
|
# maximum_block_size: 131072,
|
|
691
|
-
#
|
|
691
|
+
# hbd_interest_rate: 1000,
|
|
692
692
|
# account_subsidy_budget: 50000,
|
|
693
693
|
# account_subsidy_decay: 330782,
|
|
694
|
-
#
|
|
694
|
+
# hbd_exchange_rate: '1.000 HIVE',
|
|
695
695
|
# url: "https://hive.blog",
|
|
696
696
|
# new_signing_key: 'STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD'
|
|
697
697
|
# }
|
|
@@ -713,31 +713,33 @@ module Hive
|
|
|
713
713
|
params = options[:params]
|
|
714
714
|
check_required_fields(params, *required_fields)
|
|
715
715
|
|
|
716
|
-
|
|
717
|
-
|
|
716
|
+
props = params[:props]
|
|
717
|
+
|
|
718
|
+
if !!(account_creation_fee = props[:account_creation_fee] rescue nil)
|
|
719
|
+
props[:account_creation_fee] = hexlify normalize_amount(options.merge amount: account_creation_fee, serialize: true)
|
|
718
720
|
end
|
|
719
721
|
|
|
720
|
-
if !!(
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
722
|
+
if !!(hbd_exchange_rate = props[:hbd_exchange_rate] rescue nil)
|
|
723
|
+
props[:hbd_exchange_rate][:base] = normalize_amount(options.merge amount: hbd_exchange_rate[:base], serialize: true)
|
|
724
|
+
props[:hbd_exchange_rate][:quote] = normalize_amount(options.merge amount: hbd_exchange_rate[:quote], serialize: true)
|
|
725
|
+
props[:hbd_exchange_rate] = hexlify props[:hbd_exchange_rate].to_json
|
|
724
726
|
end
|
|
725
727
|
|
|
726
728
|
%i(key new_signing_key).each do |key|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
+
begin
|
|
730
|
+
if !!props[key] && props[key].length == 53
|
|
731
|
+
props[key] = hexlify props[key][3..-1]
|
|
732
|
+
end
|
|
733
|
+
rescue => e
|
|
734
|
+
raise Hive::ArgumentError, "Unable to parse #{key}: #{e}"
|
|
729
735
|
end
|
|
730
736
|
end
|
|
731
737
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
val = params[:props][key].to_s
|
|
736
|
-
|
|
737
|
-
params[:props][key] = hexlify val unless val =~ /^[0-9A-F]+$/i
|
|
738
|
+
if !!(val = props[:url])
|
|
739
|
+
props[:url] = hexlify val unless val =~ /^[0-9A-F]+$/i
|
|
738
740
|
end
|
|
739
741
|
|
|
740
|
-
params[:props] =
|
|
742
|
+
params[:props] = props.sort_by{|k,v| k}
|
|
741
743
|
|
|
742
744
|
params[:extensions] ||= []
|
|
743
745
|
ops = [[:witness_set_properties, params]]
|
|
@@ -955,8 +957,8 @@ module Hive
|
|
|
955
957
|
# * :to (String)
|
|
956
958
|
# * :agent (String)
|
|
957
959
|
# * :escrow_id (String)
|
|
958
|
-
# * :
|
|
959
|
-
# * :
|
|
960
|
+
# * :hbd_amount (String)
|
|
961
|
+
# * :hive_amount (String)
|
|
960
962
|
# * :fee (String)
|
|
961
963
|
# * :ratification_deadline (String)
|
|
962
964
|
# * :escrow_expiration (String)
|
|
@@ -978,8 +980,8 @@ module Hive
|
|
|
978
980
|
|
|
979
981
|
check_required_fields(params, *required_fields)
|
|
980
982
|
|
|
981
|
-
params[:
|
|
982
|
-
params[:
|
|
983
|
+
params[:hbd_amount] = normalize_amount(options.merge amount: params[:hbd_amount])
|
|
984
|
+
params[:hive_amount] = normalize_amount(options.merge amount: params[:hive_amount])
|
|
983
985
|
params[:fee] = normalize_amount(options.merge amount: params[:fee])
|
|
984
986
|
|
|
985
987
|
params[:ratification_deadline] = Time.parse(params[:ratification_deadline].to_s)
|
|
@@ -1030,8 +1032,8 @@ module Hive
|
|
|
1030
1032
|
# * :who (String)
|
|
1031
1033
|
# * :receiver (String)
|
|
1032
1034
|
# * :escrow_id (String)
|
|
1033
|
-
# * :
|
|
1034
|
-
# * :
|
|
1035
|
+
# * :hbd_amount (String)
|
|
1036
|
+
# * :hive_amount (String)
|
|
1035
1037
|
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
|
1036
1038
|
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_escrow_release
|
|
1037
1039
|
def self.escrow_release(options, &block)
|
|
@@ -1039,8 +1041,8 @@ module Hive
|
|
|
1039
1041
|
params = options[:params]
|
|
1040
1042
|
check_required_fields(params, *required_fields)
|
|
1041
1043
|
|
|
1042
|
-
params[:
|
|
1043
|
-
params[:
|
|
1044
|
+
params[:hbd_amount] = normalize_amount(options.merge amount: params[:hbd_amount])
|
|
1045
|
+
params[:hive_amount] = normalize_amount(options.merge amount: params[:hive_amount])
|
|
1044
1046
|
|
|
1045
1047
|
ops = [[:escrow_release, params]]
|
|
1046
1048
|
|
|
@@ -1239,7 +1241,124 @@ module Hive
|
|
|
1239
1241
|
|
|
1240
1242
|
process(options.merge(ops: ops), &block)
|
|
1241
1243
|
end
|
|
1242
|
-
|
|
1244
|
+
|
|
1245
|
+
# @param options [Hash] options
|
|
1246
|
+
# @option options [String] :wif Posting wif
|
|
1247
|
+
# @option options [Hash] :params
|
|
1248
|
+
# * :account (String) Account claiming rewards.
|
|
1249
|
+
# * :reward_hive (Amount) Amount of HIVE to claim.
|
|
1250
|
+
# * :reward_hbd (Amount) Amount of HBD to claim.
|
|
1251
|
+
# * :reward_vests (Amount) Amount of VESTS to claim.
|
|
1252
|
+
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
|
1253
|
+
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_claim_reward_balance
|
|
1254
|
+
def self.claim_reward_balance(options, &block)
|
|
1255
|
+
required_fields = %i(account)
|
|
1256
|
+
params = options[:params]
|
|
1257
|
+
|
|
1258
|
+
check_required_fields(params, *required_fields)
|
|
1259
|
+
|
|
1260
|
+
params[:reward_hive] = normalize_amount(options.merge amount: params[:reward_hive])
|
|
1261
|
+
params[:reward_hbd] = normalize_amount(options.merge amount: params[:reward_hbd])
|
|
1262
|
+
params[:reward_vests] = normalize_amount(options.merge amount: params[:reward_vests])
|
|
1263
|
+
|
|
1264
|
+
ops = [[:claim_reward_balance, params]]
|
|
1265
|
+
|
|
1266
|
+
process(options.merge(ops: ops), &block)
|
|
1267
|
+
end
|
|
1268
|
+
|
|
1269
|
+
# @param options [Hash] options
|
|
1270
|
+
# @option options [String] :wif Active wif
|
|
1271
|
+
# @option options [Hash] :params
|
|
1272
|
+
# * :account (String) Account being updated.
|
|
1273
|
+
# * :metadata (Hash) Metadata of the account, becomes `json_metadata`.
|
|
1274
|
+
# * :json_metadata (String) String version of `metadata` (use one or the other).
|
|
1275
|
+
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
|
1276
|
+
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_account_update2
|
|
1277
|
+
def self.account_update2(options, &block)
|
|
1278
|
+
required_fields = %i(account)
|
|
1279
|
+
params = options[:params]
|
|
1280
|
+
|
|
1281
|
+
check_required_fields(params, *required_fields)
|
|
1282
|
+
|
|
1283
|
+
if !!params[:metadata] && !!params[:json_metadata]
|
|
1284
|
+
raise Hive::ArgumentError, 'Assign either metadata or json_metadata, not both.'
|
|
1285
|
+
end
|
|
1286
|
+
|
|
1287
|
+
metadata = params.delete(:metadata) || {}
|
|
1288
|
+
metadata ||= (JSON[params[:json_metadata]] || nil) || {}
|
|
1289
|
+
params[:json_metadata] = metadata.to_json
|
|
1290
|
+
|
|
1291
|
+
ops = [[:account_update2, params]]
|
|
1292
|
+
|
|
1293
|
+
process(options.merge(ops: ops), &block)
|
|
1294
|
+
end
|
|
1295
|
+
|
|
1296
|
+
# @param options [Hash] options
|
|
1297
|
+
# @option options [String] :wif Active wif
|
|
1298
|
+
# @option options [Hash] :params
|
|
1299
|
+
# * :creator (String) Creator of the new proposal.
|
|
1300
|
+
# * :receiver (String) Reciever of `daily_pay` (or creator if empty)
|
|
1301
|
+
# * :start_date (String) When the proposal starts.
|
|
1302
|
+
# * :end_date (String) When the proposal ends.
|
|
1303
|
+
# * :daily_pay (String) Daily pay in HBD starting on the `start_date` and ending on the `end_date`.
|
|
1304
|
+
# * :subject (String) Subject of the proposal.
|
|
1305
|
+
# * :permlink (String) Proposal permlink must point to the article posted by creator or receiver.
|
|
1306
|
+
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
|
1307
|
+
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_create_proposal
|
|
1308
|
+
def self.create_proposal(options, &block)
|
|
1309
|
+
required_fields = %i(creator start_date end_date daily_pay subject permlink)
|
|
1310
|
+
params = options[:params]
|
|
1311
|
+
|
|
1312
|
+
check_required_fields(params, *required_fields)
|
|
1313
|
+
|
|
1314
|
+
params[:start_date] = Time.parse(params[:start_date].to_s)
|
|
1315
|
+
params[:start_date] = params[:start_date].strftime('%Y-%m-%dT%H:%M:%S')
|
|
1316
|
+
params[:end_date] = Time.parse(params[:end_date].to_s)
|
|
1317
|
+
params[:end_date] = params[:end_date].strftime('%Y-%m-%dT%H:%M:%S')
|
|
1318
|
+
params[:daily_pay] = normalize_amount(options.merge amount: params[:daily_pay])
|
|
1319
|
+
|
|
1320
|
+
ops = [[:create_proposal, params]]
|
|
1321
|
+
|
|
1322
|
+
process(options.merge(ops: ops), &block)
|
|
1323
|
+
end
|
|
1324
|
+
|
|
1325
|
+
# @param options [Hash] options
|
|
1326
|
+
# @option options [String] :wif Active wif
|
|
1327
|
+
# @option options [Hash] :params
|
|
1328
|
+
# * :voter (String) Account doing approval (or removing approval).
|
|
1329
|
+
# * :proposal_ids (Array<Integer>) Proposals to approve (or remove approval) for.
|
|
1330
|
+
# * :approve (Boolean) Approve or unapprove.
|
|
1331
|
+
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
|
1332
|
+
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_update_proposal_votes
|
|
1333
|
+
def self.update_proposal_votes(options, &block)
|
|
1334
|
+
required_fields = %i(voter proposal_ids approve)
|
|
1335
|
+
params = options[:params]
|
|
1336
|
+
|
|
1337
|
+
check_required_fields(params, *required_fields)
|
|
1338
|
+
|
|
1339
|
+
ops = [[:update_proposal_votes, params]]
|
|
1340
|
+
|
|
1341
|
+
process(options.merge(ops: ops), &block)
|
|
1342
|
+
end
|
|
1343
|
+
|
|
1344
|
+
# @param options [Hash] options
|
|
1345
|
+
# @option options [String] :wif Active wif
|
|
1346
|
+
# @option options [Hash] :params
|
|
1347
|
+
# * :proposal_owner (String) Creator of the proposal.
|
|
1348
|
+
# * :proposal_ids (Array<Integer>) Proposals to remove.
|
|
1349
|
+
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
|
1350
|
+
# @see https://developers.hive.io/apidefinitions/broadcast-ops.html#broadcast_ops_update_proposal_votes
|
|
1351
|
+
def self.remove_proposal(options, &block)
|
|
1352
|
+
required_fields = %i(proposal_owner proposal_ids)
|
|
1353
|
+
params = options[:params]
|
|
1354
|
+
|
|
1355
|
+
check_required_fields(params, *required_fields)
|
|
1356
|
+
|
|
1357
|
+
ops = [[:remove_proposal, params]]
|
|
1358
|
+
|
|
1359
|
+
process(options.merge(ops: ops), &block)
|
|
1360
|
+
end
|
|
1361
|
+
|
|
1243
1362
|
# @param options [Hash] options
|
|
1244
1363
|
# @option options [Array<Array<Hash>] :ops Operations to process.
|
|
1245
1364
|
# @option options [Boolean] :pretend Just validate, do not broadcast.
|
data/lib/hive/fallback.rb
CHANGED
|
@@ -106,7 +106,6 @@ module Hive::Fallback
|
|
|
106
106
|
:find_limit_orders,
|
|
107
107
|
:find_owner_histories,
|
|
108
108
|
:find_savings_withdrawals,
|
|
109
|
-
:find_sbd_conversion_requests,
|
|
110
109
|
:find_vesting_delegation_expirations,
|
|
111
110
|
:find_vesting_delegations,
|
|
112
111
|
:find_votes,
|
|
@@ -134,7 +133,6 @@ module Hive::Fallback
|
|
|
134
133
|
:list_limit_orders,
|
|
135
134
|
:list_owner_histories,
|
|
136
135
|
:list_savings_withdrawals,
|
|
137
|
-
:list_sbd_conversion_requests,
|
|
138
136
|
:list_vesting_delegation_expirations,
|
|
139
137
|
:list_vesting_delegations,
|
|
140
138
|
:list_votes,
|
|
@@ -208,11 +206,25 @@ module Hive::Fallback
|
|
|
208
206
|
:get_account_reputations
|
|
209
207
|
],
|
|
210
208
|
bridge: [
|
|
209
|
+
:normalize_post,
|
|
210
|
+
:get_post_header,
|
|
211
|
+
:get_discussion,
|
|
212
|
+
:get_post,
|
|
213
|
+
:get_account_posts,
|
|
214
|
+
:get_ranked_posts,
|
|
215
|
+
:get_profile,
|
|
216
|
+
:get_trending_topics,
|
|
217
|
+
:post_notifications,
|
|
211
218
|
:account_notifications,
|
|
219
|
+
:unread_notifications,
|
|
220
|
+
:get_payout_stats,
|
|
212
221
|
:get_community,
|
|
213
|
-
:
|
|
222
|
+
:get_community_context,
|
|
223
|
+
:list_pop_communities,
|
|
224
|
+
:list_subscribers,
|
|
214
225
|
:list_all_subscriptions,
|
|
215
226
|
:list_community_roles,
|
|
227
|
+
:list_communities
|
|
216
228
|
]
|
|
217
229
|
}
|
|
218
230
|
|
|
@@ -228,7 +240,7 @@ module Hive::Fallback
|
|
|
228
240
|
find_owner_histories: {owner: String},
|
|
229
241
|
find_proposals: {proposal_ids: []},
|
|
230
242
|
find_savings_withdrawals: {account: String},
|
|
231
|
-
|
|
243
|
+
find_hbd_conversion_requests: {account: String},
|
|
232
244
|
find_vesting_delegation_expirations: {account: String},
|
|
233
245
|
find_vesting_delegations: {account: String},
|
|
234
246
|
find_votes: {author: String, permlink: String},
|
|
@@ -258,7 +270,7 @@ module Hive::Fallback
|
|
|
258
270
|
list_proposal_votes: {start: NilClass, limit: Integer, order: String, order_direction: String, status: String},
|
|
259
271
|
list_proposals: {start: NilClass, limit: Integer, order: String, order_direction: String, status: String},
|
|
260
272
|
list_savings_withdrawals: {start: NilClass, limit: Integer, order: String},
|
|
261
|
-
|
|
273
|
+
list_hbd_conversion_requests: {start: NilClass, limit: Integer, order: String},
|
|
262
274
|
list_vesting_delegation_expirations: {start: NilClass, limit: Integer, order: String},
|
|
263
275
|
list_vesting_delegations: {start: NilClass, limit: Integer, order: String},
|
|
264
276
|
list_votes: {start: NilClass, limit: Integer, order: String},
|
|
@@ -277,11 +289,25 @@ module Hive::Fallback
|
|
|
277
289
|
get_account_reputations: {account_lower_bound: String, limit: Integer}
|
|
278
290
|
},
|
|
279
291
|
bridge: {
|
|
280
|
-
|
|
292
|
+
normalize_post: {post: Hash},
|
|
293
|
+
get_post_header: {author: String, permlink: String},
|
|
294
|
+
get_discussion: {author: String, permlink: String},
|
|
295
|
+
get_post: {author: String, permlink: String, observer: String},
|
|
296
|
+
get_account_posts: {sort: String, account: String, start_account: String, start_permlink: String, limit: Integer, observer: String},
|
|
297
|
+
get_ranked_posts: {sort: String, tag: String, observer: String, limit: Integer, start_author: String, start_permlink: String},
|
|
298
|
+
get_profile: {account: String, observer: String},
|
|
299
|
+
get_trending_topics: {limit: Integer, observer: String},
|
|
300
|
+
post_notifications: {author: String, permlink: String, min_score: Integer, last_id: String, limit: Integer},
|
|
301
|
+
account_notifications: {account: String, min_score: Integer, last_id: Integer, limit: Integer},
|
|
302
|
+
unread_notifications: {account: String, min_score: Integer},
|
|
303
|
+
get_payout_stats: {limit: Integer},
|
|
281
304
|
get_community: {name: String, observer: String},
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
305
|
+
get_community_context: {name: String, account: String},
|
|
306
|
+
list_communities: {last: String, limit: Integer, query: String, sort: String, observer: String},
|
|
307
|
+
list_pop_communities: {limit: Integer},
|
|
308
|
+
list_community_roles: {community: String, last: String, limit: Integer},
|
|
309
|
+
list_subscribers: {community: String},
|
|
310
|
+
list_all_subscriptions: {account: String}
|
|
285
311
|
}
|
|
286
312
|
}
|
|
287
313
|
end
|
data/lib/hive/jsonrpc.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Hive
|
|
|
11
11
|
|
|
12
12
|
# APIs that the RPC server will (or likely will) respond to that is
|
|
13
13
|
# maintained outside the view of jsonrpc.
|
|
14
|
-
UNLISTED_APIS = %i(bridge)
|
|
14
|
+
UNLISTED_APIS = %i(bridge database_api)
|
|
15
15
|
|
|
16
16
|
def self.api_methods
|
|
17
17
|
@api_methods ||= {}
|
|
@@ -90,7 +90,7 @@ module Hive
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
for request_object in chunks do
|
|
93
|
-
@rpc_client.rpc_batch_execute(request_object: request_object) do |result, error, id|
|
|
93
|
+
@rpc_client.rpc_batch_execute(api_name: self.class.api_name, request_object: request_object) do |result, error, id|
|
|
94
94
|
api, method = method_map[id]
|
|
95
95
|
api = api.to_sym
|
|
96
96
|
method = method.to_sym
|
data/lib/hive/marshal.rb
CHANGED
|
@@ -144,7 +144,7 @@ module Hive
|
|
|
144
144
|
{
|
|
145
145
|
account_creation_fee: amount,
|
|
146
146
|
maximum_block_size: uint32,
|
|
147
|
-
|
|
147
|
+
hbd_interest_rate: uint16
|
|
148
148
|
}
|
|
149
149
|
end
|
|
150
150
|
|
|
@@ -159,17 +159,16 @@ module Hive
|
|
|
159
159
|
key = string.to_sym
|
|
160
160
|
properties[key] = case key
|
|
161
161
|
when :account_creation_fee then Hive::Type::Amount.new(string)
|
|
162
|
-
when :account_subsidy_budget then
|
|
163
|
-
when :account_subsidy_decay, :maximum_block_size then uint32
|
|
164
|
-
when :
|
|
165
|
-
when :sbd_exchange_rate
|
|
162
|
+
# when :account_subsidy_budget then int32
|
|
163
|
+
# when :account_subsidy_decay, :maximum_block_size then uint32
|
|
164
|
+
when :hbd_exchange_rate
|
|
166
165
|
JSON[string].tap do |rate|
|
|
167
166
|
rate["base"] = Hive::Type::Amount.new(rate["base"])
|
|
168
167
|
rate["quote"] = Hive::Type::Amount.new(rate["quote"])
|
|
169
168
|
end
|
|
170
|
-
when :
|
|
171
|
-
when :key, :new_signing_key then
|
|
172
|
-
else;
|
|
169
|
+
# when :hbd_interest_rate then uint16
|
|
170
|
+
when :url, :key, :new_signing_key then string
|
|
171
|
+
else; warn "Unsupported witness property: #{key}"
|
|
173
172
|
end
|
|
174
173
|
end
|
|
175
174
|
|
|
@@ -180,6 +179,10 @@ module Hive
|
|
|
180
179
|
unsigned_char == 0 and [] or raise "Found non-empty array."
|
|
181
180
|
end
|
|
182
181
|
|
|
182
|
+
def uint64_array
|
|
183
|
+
varint.times{ uint64 }
|
|
184
|
+
end
|
|
185
|
+
|
|
183
186
|
def transaction(options = {})
|
|
184
187
|
trx = options[:trx] || Transaction.new
|
|
185
188
|
|
|
@@ -6,7 +6,7 @@ module Hive
|
|
|
6
6
|
KNOWN_TYPES = NUMERIC_TYPES + %i(boolean string raw_bytes point_in_time
|
|
7
7
|
public_key amount price authority optional_authority
|
|
8
8
|
comment_options_extensions beneficiaries chain_properties required_auths
|
|
9
|
-
witness_properties empty_array lambda)
|
|
9
|
+
witness_properties uint64_array empty_array lambda)
|
|
10
10
|
|
|
11
11
|
module ClassMethods
|
|
12
12
|
def def_attr key_pair
|
data/lib/hive/operation.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Hive
|
|
|
5
5
|
include Utils
|
|
6
6
|
|
|
7
7
|
# IDs derrived from:
|
|
8
|
-
# https://
|
|
8
|
+
# https://gitlab.syncad.com/hive/hive/-/blob/master/libraries/protocol/include/steem/protocol/operations.hpp
|
|
9
9
|
|
|
10
10
|
IDS = [
|
|
11
11
|
:vote_operation,
|
|
@@ -60,6 +60,10 @@ module Hive
|
|
|
60
60
|
:delegate_vesting_shares_operation,
|
|
61
61
|
:account_create_with_delegation_operation,
|
|
62
62
|
:witness_set_properties_operation,
|
|
63
|
+
:account_update2_operation,
|
|
64
|
+
:create_proposal_operation,
|
|
65
|
+
:update_proposal_votes_operation,
|
|
66
|
+
:remove_proposal_operation,
|
|
63
67
|
|
|
64
68
|
# SMT operations
|
|
65
69
|
:claim_reward_balance2_operation,
|
|
@@ -2,7 +2,7 @@ class Hive::Operation::CommentOptions < Hive::Operation
|
|
|
2
2
|
def_attr author: :string
|
|
3
3
|
def_attr permlink: :string
|
|
4
4
|
def_attr max_accepted_payout: :amount
|
|
5
|
-
def_attr
|
|
5
|
+
def_attr percent_hbd: :uint32
|
|
6
6
|
# def_attr allow_replies: :boolean
|
|
7
7
|
def_attr allow_votes: :boolean
|
|
8
8
|
def_attr allow_curation_rewards: :boolean
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
class Hive::Operation::CreateProposal < Hive::Operation
|
|
2
|
+
def_attr creator: :string
|
|
3
|
+
def_attr receiver: :string
|
|
4
|
+
def_attr start_date: :point_in_time
|
|
5
|
+
def_attr end_date: :point_in_time
|
|
6
|
+
def_attr daily_pay: :amount
|
|
7
|
+
def_attr subject: :string
|
|
8
|
+
def_attr permlink: :string
|
|
9
|
+
end
|
|
@@ -5,6 +5,6 @@ class Hive::Operation::EscrowRelease < Hive::Operation
|
|
|
5
5
|
def_attr who: :string
|
|
6
6
|
def_attr receiver: :string
|
|
7
7
|
def_attr escrow_id: :uint32
|
|
8
|
-
def_attr
|
|
9
|
-
def_attr
|
|
8
|
+
def_attr hbd_amount: :amount
|
|
9
|
+
def_attr hive_amount: :amount
|
|
10
10
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class Hive::Operation::EscrowTransfer < Hive::Operation
|
|
2
2
|
def_attr from: :string
|
|
3
3
|
def_attr to: :string
|
|
4
|
-
def_attr
|
|
5
|
-
def_attr
|
|
4
|
+
def_attr hbd_amount: :amount
|
|
5
|
+
def_attr hive_amount: :amount
|
|
6
6
|
def_attr escrow_id: :uint32
|
|
7
7
|
def_attr agent: :string
|
|
8
8
|
def_attr fee: :amount
|
data/lib/hive/rpc/http_client.rb
CHANGED
|
@@ -17,7 +17,9 @@ module Hive
|
|
|
17
17
|
#
|
|
18
18
|
# @private
|
|
19
19
|
TIMEOUT_ERRORS = [Net::OpenTimeout, JSON::ParserError, Net::ReadTimeout,
|
|
20
|
-
Errno::EBADF, IOError, Errno::ENETDOWN, Hive::RemoteDatabaseLockError
|
|
20
|
+
Errno::EBADF, IOError, Errno::ENETDOWN, Hive::RemoteDatabaseLockError,
|
|
21
|
+
Hive::RequestTimeoutUpstreamResponseError, Hive::RemoteServerError,
|
|
22
|
+
Hive::RemoteServerError]
|
|
21
23
|
|
|
22
24
|
# @private
|
|
23
25
|
POST_HEADERS = {
|
|
@@ -57,8 +59,10 @@ module Hive
|
|
|
57
59
|
def rpc_execute(api_name = @api_name, api_method = nil, options = {}, &block)
|
|
58
60
|
reset_timeout
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
response = nil
|
|
63
|
+
|
|
64
|
+
loop do
|
|
65
|
+
request = http_post(api_name)
|
|
62
66
|
|
|
63
67
|
request_object = if !!api_name && !!api_method
|
|
64
68
|
put(api_name, api_method, options)
|
|
@@ -80,11 +84,11 @@ module Hive
|
|
|
80
84
|
|
|
81
85
|
response = catch :http_request do; begin; http_request(request)
|
|
82
86
|
rescue *TIMEOUT_ERRORS => e
|
|
83
|
-
|
|
87
|
+
retry_timeout(:http_request, e) and redo
|
|
84
88
|
end; end
|
|
85
89
|
|
|
86
90
|
if response.nil?
|
|
87
|
-
|
|
91
|
+
retry_timeout(:tota_cera_pila, 'response was nil') and redo
|
|
88
92
|
end
|
|
89
93
|
|
|
90
94
|
case response.code
|
|
@@ -108,6 +112,9 @@ module Hive
|
|
|
108
112
|
else; response
|
|
109
113
|
end
|
|
110
114
|
|
|
115
|
+
timeout_detected = false
|
|
116
|
+
timeout_cause = nil
|
|
117
|
+
|
|
111
118
|
[response].flatten.each_with_index do |r, i|
|
|
112
119
|
if defined?(r.error) && !!r.error
|
|
113
120
|
if !!r.error.message
|
|
@@ -116,7 +123,10 @@ module Hive
|
|
|
116
123
|
rpc_args = [request_object].flatten[i]
|
|
117
124
|
raise_error_response rpc_method_name, rpc_args, r
|
|
118
125
|
rescue *TIMEOUT_ERRORS => e
|
|
119
|
-
|
|
126
|
+
timeout_detected = true
|
|
127
|
+
timeout_cause = nil
|
|
128
|
+
|
|
129
|
+
break # fail fast
|
|
120
130
|
end
|
|
121
131
|
else
|
|
122
132
|
raise Hive::ArgumentError, r.error.inspect
|
|
@@ -124,19 +134,29 @@ module Hive
|
|
|
124
134
|
end
|
|
125
135
|
end
|
|
126
136
|
|
|
137
|
+
if timeout_detected
|
|
138
|
+
retry_timeout(:tota_cera_pila, timeout_cause) and redo
|
|
139
|
+
end
|
|
140
|
+
|
|
127
141
|
yield_response response, &block
|
|
128
142
|
when '504' # Gateway Timeout
|
|
129
|
-
|
|
143
|
+
retry_timeout(:tota_cera_pila, response.body) and redo
|
|
130
144
|
when '502' # Bad Gateway
|
|
131
|
-
|
|
145
|
+
retry_timeout(:tota_cera_pila, response.body) and redo
|
|
132
146
|
else
|
|
133
147
|
raise UnknownError, "#{api_name}.#{api_method}: #{response.body}"
|
|
134
148
|
end
|
|
135
|
-
|
|
149
|
+
|
|
150
|
+
break # success!
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
response
|
|
136
154
|
end
|
|
137
155
|
|
|
138
156
|
def rpc_batch_execute(options = {}, &block)
|
|
139
|
-
|
|
157
|
+
api_name = options[:api_name]
|
|
158
|
+
|
|
159
|
+
yield_response rpc_execute(api_name, nil, options), &block
|
|
140
160
|
end
|
|
141
161
|
end
|
|
142
162
|
end
|
|
@@ -10,13 +10,20 @@ module Hive
|
|
|
10
10
|
class ThreadSafeHttpClient < HttpClient
|
|
11
11
|
SEMAPHORE = Mutex.new.freeze
|
|
12
12
|
|
|
13
|
-
# Same as #{HttpClient#http_post}, but scoped to each thread
|
|
14
|
-
# thread safe.
|
|
15
|
-
def http_post
|
|
13
|
+
# Same as #{HttpClient#http_post}, but scoped to each thread, uri, and
|
|
14
|
+
# api_name so it is thread safe.
|
|
15
|
+
def http_post(api_name)
|
|
16
|
+
raise "Namespace required." if api_name.nil?
|
|
17
|
+
|
|
16
18
|
thread = Thread.current
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
http_posts = thread.thread_variable_get(:http_posts) || {}
|
|
20
|
+
|
|
21
|
+
SEMAPHORE.synchronize do
|
|
22
|
+
http_posts[[uri, api_name]] ||= Net::HTTP::Post.new(uri.request_uri, POST_HEADERS)
|
|
23
|
+
thread.thread_variable_set(:http_posts, http_posts)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
http_posts[[uri, api_name]]
|
|
20
27
|
end
|
|
21
28
|
|
|
22
29
|
def http_request(request); SEMAPHORE.synchronize{super}; end
|
data/lib/hive/stream.rb
CHANGED
|
@@ -173,7 +173,7 @@ module Hive
|
|
|
173
173
|
# stream = Hive::Stream.new
|
|
174
174
|
# stream.operations(types: :author_reward_operation, only_virtual: true) do |vop|
|
|
175
175
|
# v = vop.value
|
|
176
|
-
# puts "#{v.author} got paid for #{v.permlink}: #{[v.
|
|
176
|
+
# puts "#{v.author} got paid for #{v.permlink}: #{[v.hbd_payout, v.hive_payout, v.vesting_payout]}"
|
|
177
177
|
# end
|
|
178
178
|
#
|
|
179
179
|
# ... or multiple virtual operation types;
|
data/lib/hive/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hive-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anthony Martin
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -16,20 +16,20 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1
|
|
19
|
+
version: '2.1'
|
|
20
20
|
- - ">="
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 1.
|
|
22
|
+
version: 2.1.4
|
|
23
23
|
type: :development
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - "~>"
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '1
|
|
29
|
+
version: '2.1'
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 1.
|
|
32
|
+
version: 2.1.4
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: rake
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -54,22 +54,22 @@ dependencies:
|
|
|
54
54
|
name: minitest
|
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
|
-
- - "~>"
|
|
58
|
-
- !ruby/object:Gem::Version
|
|
59
|
-
version: '5.10'
|
|
60
57
|
- - ">="
|
|
61
58
|
- !ruby/object:Gem::Version
|
|
62
59
|
version: 5.10.3
|
|
60
|
+
- - "~>"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '5.14'
|
|
63
63
|
type: :development
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
|
-
- - "~>"
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
version: '5.10'
|
|
70
67
|
- - ">="
|
|
71
68
|
- !ruby/object:Gem::Version
|
|
72
69
|
version: 5.10.3
|
|
70
|
+
- - "~>"
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '5.14'
|
|
73
73
|
- !ruby/object:Gem::Dependency
|
|
74
74
|
name: minitest-line
|
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -159,7 +159,7 @@ dependencies:
|
|
|
159
159
|
version: 4.0.0
|
|
160
160
|
- - "~>"
|
|
161
161
|
- !ruby/object:Gem::Version
|
|
162
|
-
version: '
|
|
162
|
+
version: '6.0'
|
|
163
163
|
type: :development
|
|
164
164
|
prerelease: false
|
|
165
165
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -169,7 +169,7 @@ dependencies:
|
|
|
169
169
|
version: 4.0.0
|
|
170
170
|
- - "~>"
|
|
171
171
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: '
|
|
172
|
+
version: '6.0'
|
|
173
173
|
- !ruby/object:Gem::Dependency
|
|
174
174
|
name: yard
|
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -294,22 +294,22 @@ dependencies:
|
|
|
294
294
|
name: hashie
|
|
295
295
|
requirement: !ruby/object:Gem::Requirement
|
|
296
296
|
requirements:
|
|
297
|
-
- - "~>"
|
|
298
|
-
- !ruby/object:Gem::Version
|
|
299
|
-
version: '3.5'
|
|
300
297
|
- - ">="
|
|
301
298
|
- !ruby/object:Gem::Version
|
|
302
299
|
version: 3.5.7
|
|
300
|
+
- - "~>"
|
|
301
|
+
- !ruby/object:Gem::Version
|
|
302
|
+
version: '4.1'
|
|
303
303
|
type: :runtime
|
|
304
304
|
prerelease: false
|
|
305
305
|
version_requirements: !ruby/object:Gem::Requirement
|
|
306
306
|
requirements:
|
|
307
|
-
- - "~>"
|
|
308
|
-
- !ruby/object:Gem::Version
|
|
309
|
-
version: '3.5'
|
|
310
307
|
- - ">="
|
|
311
308
|
- !ruby/object:Gem::Version
|
|
312
309
|
version: 3.5.7
|
|
310
|
+
- - "~>"
|
|
311
|
+
- !ruby/object:Gem::Version
|
|
312
|
+
version: '4.1'
|
|
313
313
|
- !ruby/object:Gem::Dependency
|
|
314
314
|
name: bitcoin-ruby
|
|
315
315
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -317,9 +317,9 @@ dependencies:
|
|
|
317
317
|
- - "~>"
|
|
318
318
|
- !ruby/object:Gem::Version
|
|
319
319
|
version: '0.0'
|
|
320
|
-
- -
|
|
320
|
+
- - '='
|
|
321
321
|
- !ruby/object:Gem::Version
|
|
322
|
-
version: 0.0.
|
|
322
|
+
version: 0.0.20
|
|
323
323
|
type: :runtime
|
|
324
324
|
prerelease: false
|
|
325
325
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -327,9 +327,9 @@ dependencies:
|
|
|
327
327
|
- - "~>"
|
|
328
328
|
- !ruby/object:Gem::Version
|
|
329
329
|
version: '0.0'
|
|
330
|
-
- -
|
|
330
|
+
- - '='
|
|
331
331
|
- !ruby/object:Gem::Version
|
|
332
|
-
version: 0.0.
|
|
332
|
+
version: 0.0.20
|
|
333
333
|
- !ruby/object:Gem::Dependency
|
|
334
334
|
name: ffi
|
|
335
335
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -398,12 +398,15 @@ extensions: []
|
|
|
398
398
|
extra_rdoc_files: []
|
|
399
399
|
files:
|
|
400
400
|
- ".gitignore"
|
|
401
|
+
- ".gitlab-ci.yml"
|
|
401
402
|
- CONTRIBUTING.md
|
|
402
403
|
- Gemfile
|
|
403
|
-
- Gemfile.lock
|
|
404
404
|
- LICENSE
|
|
405
405
|
- README.md
|
|
406
406
|
- Rakefile
|
|
407
|
+
- assets/logo-128.png
|
|
408
|
+
- assets/logo.png
|
|
409
|
+
- assets/logo.xcf
|
|
407
410
|
- gource.sh
|
|
408
411
|
- hive-ruby.gemspec
|
|
409
412
|
- images/Anthony Martin.png
|
|
@@ -425,6 +428,7 @@ files:
|
|
|
425
428
|
- lib/hive/operation/account_create.rb
|
|
426
429
|
- lib/hive/operation/account_create_with_delegation.rb
|
|
427
430
|
- lib/hive/operation/account_update.rb
|
|
431
|
+
- lib/hive/operation/account_update2.rb
|
|
428
432
|
- lib/hive/operation/account_witness_proxy.rb
|
|
429
433
|
- lib/hive/operation/account_witness_vote.rb
|
|
430
434
|
- lib/hive/operation/cancel_transfer_from_savings.rb
|
|
@@ -436,6 +440,7 @@ files:
|
|
|
436
440
|
- lib/hive/operation/comment_options.rb
|
|
437
441
|
- lib/hive/operation/convert.rb
|
|
438
442
|
- lib/hive/operation/create_claimed_account.rb
|
|
443
|
+
- lib/hive/operation/create_proposal.rb
|
|
439
444
|
- lib/hive/operation/custom.rb
|
|
440
445
|
- lib/hive/operation/custom_binary.rb
|
|
441
446
|
- lib/hive/operation/custom_json.rb
|
|
@@ -452,6 +457,7 @@ files:
|
|
|
452
457
|
- lib/hive/operation/limit_order_create2.rb
|
|
453
458
|
- lib/hive/operation/prove_authority.rb
|
|
454
459
|
- lib/hive/operation/recover_account.rb
|
|
460
|
+
- lib/hive/operation/remove_proposal.rb
|
|
455
461
|
- lib/hive/operation/report_over_production.rb
|
|
456
462
|
- lib/hive/operation/request_account_recovery.rb
|
|
457
463
|
- lib/hive/operation/reset_account.rb
|
|
@@ -461,6 +467,7 @@ files:
|
|
|
461
467
|
- lib/hive/operation/transfer_from_savings.rb
|
|
462
468
|
- lib/hive/operation/transfer_to_savings.rb
|
|
463
469
|
- lib/hive/operation/transfer_to_vesting.rb
|
|
470
|
+
- lib/hive/operation/update_proposal_votes.rb
|
|
464
471
|
- lib/hive/operation/vote.rb
|
|
465
472
|
- lib/hive/operation/withdraw_vesting.rb
|
|
466
473
|
- lib/hive/operation/witness_set_properties.rb
|
|
@@ -479,7 +486,7 @@ homepage: https://gitlab.syncad.com/hive/hive-ruby
|
|
|
479
486
|
licenses:
|
|
480
487
|
- MIT
|
|
481
488
|
metadata: {}
|
|
482
|
-
post_install_message:
|
|
489
|
+
post_install_message:
|
|
483
490
|
rdoc_options: []
|
|
484
491
|
require_paths:
|
|
485
492
|
- lib
|
|
@@ -490,13 +497,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
490
497
|
version: '0'
|
|
491
498
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
492
499
|
requirements:
|
|
493
|
-
- - "
|
|
500
|
+
- - ">="
|
|
494
501
|
- !ruby/object:Gem::Version
|
|
495
|
-
version:
|
|
502
|
+
version: '0'
|
|
496
503
|
requirements: []
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
signing_key:
|
|
504
|
+
rubygems_version: 3.0.8
|
|
505
|
+
signing_key:
|
|
500
506
|
specification_version: 4
|
|
501
507
|
summary: Hive Ruby Client
|
|
502
508
|
test_files: []
|
data/Gemfile.lock
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
hive-ruby (1.0.0.pre.1)
|
|
5
|
-
base58 (~> 0.2, >= 0.2.3)
|
|
6
|
-
bindata (~> 2.4, >= 2.4.4)
|
|
7
|
-
bitcoin-ruby (~> 0.0, >= 0.0.18)
|
|
8
|
-
ffi (~> 1.9, >= 1.9.23)
|
|
9
|
-
hashie (~> 3.5, >= 3.5.7)
|
|
10
|
-
json (~> 2.1, >= 2.1.0)
|
|
11
|
-
logging (~> 2.2, >= 2.2.0)
|
|
12
|
-
|
|
13
|
-
GEM
|
|
14
|
-
remote: https://rubygems.org/
|
|
15
|
-
specs:
|
|
16
|
-
addressable (2.7.0)
|
|
17
|
-
public_suffix (>= 2.0.2, < 5.0)
|
|
18
|
-
awesome_print (1.8.0)
|
|
19
|
-
base58 (0.2.3)
|
|
20
|
-
bindata (2.4.7)
|
|
21
|
-
bitcoin-ruby (0.0.20)
|
|
22
|
-
eventmachine
|
|
23
|
-
ffi
|
|
24
|
-
scrypt
|
|
25
|
-
coderay (1.1.2)
|
|
26
|
-
crack (0.4.3)
|
|
27
|
-
safe_yaml (~> 1.0.0)
|
|
28
|
-
docile (1.3.2)
|
|
29
|
-
eventmachine (1.2.7)
|
|
30
|
-
ffi (1.12.2)
|
|
31
|
-
ffi-compiler (1.0.1)
|
|
32
|
-
ffi (>= 1.0.0)
|
|
33
|
-
rake
|
|
34
|
-
hashdiff (1.0.1)
|
|
35
|
-
hashie (3.6.0)
|
|
36
|
-
io-console (0.5.6)
|
|
37
|
-
irb (1.2.4)
|
|
38
|
-
reline (>= 0.0.1)
|
|
39
|
-
json (2.3.0)
|
|
40
|
-
little-plugger (1.1.4)
|
|
41
|
-
logging (2.2.2)
|
|
42
|
-
little-plugger (~> 1.1)
|
|
43
|
-
multi_json (~> 1.10)
|
|
44
|
-
method_source (1.0.0)
|
|
45
|
-
minitest (5.14.0)
|
|
46
|
-
minitest-line (0.6.5)
|
|
47
|
-
minitest (~> 5.0)
|
|
48
|
-
minitest-proveit (1.0.0)
|
|
49
|
-
minitest (> 5, < 7)
|
|
50
|
-
multi_json (1.14.1)
|
|
51
|
-
pry (0.13.1)
|
|
52
|
-
coderay (~> 1.1)
|
|
53
|
-
method_source (~> 1.0)
|
|
54
|
-
public_suffix (4.0.4)
|
|
55
|
-
rake (13.0.1)
|
|
56
|
-
reline (0.1.4)
|
|
57
|
-
io-console (~> 0.5)
|
|
58
|
-
safe_yaml (1.0.5)
|
|
59
|
-
scrypt (3.0.7)
|
|
60
|
-
ffi-compiler (>= 1.0, < 2.0)
|
|
61
|
-
simplecov (0.18.5)
|
|
62
|
-
docile (~> 1.1)
|
|
63
|
-
simplecov-html (~> 0.11)
|
|
64
|
-
simplecov-html (0.12.2)
|
|
65
|
-
vcr (5.1.0)
|
|
66
|
-
webmock (3.8.3)
|
|
67
|
-
addressable (>= 2.3.6)
|
|
68
|
-
crack (>= 0.3.2)
|
|
69
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
|
70
|
-
yard (0.9.25)
|
|
71
|
-
|
|
72
|
-
PLATFORMS
|
|
73
|
-
ruby
|
|
74
|
-
|
|
75
|
-
DEPENDENCIES
|
|
76
|
-
awesome_print (~> 1.8, >= 1.8.0)
|
|
77
|
-
bundler (~> 1.16, >= 1.16.1)
|
|
78
|
-
hive-ruby!
|
|
79
|
-
irb (~> 1.2, >= 1.2.3)
|
|
80
|
-
minitest (~> 5.10, >= 5.10.3)
|
|
81
|
-
minitest-line (~> 0.6, >= 0.6.4)
|
|
82
|
-
minitest-proveit (~> 1.0, >= 1.0.0)
|
|
83
|
-
pry (~> 0.11, >= 0.11.3)
|
|
84
|
-
rake (~> 13.0.1, >= 12.3.0)
|
|
85
|
-
simplecov (~> 0.15, >= 0.15.1)
|
|
86
|
-
vcr (~> 5.1, >= 4.0.0)
|
|
87
|
-
webmock (~> 3.3, >= 3.3.0)
|
|
88
|
-
yard (~> 0.9, >= 0.9.12)
|
|
89
|
-
|
|
90
|
-
BUNDLED WITH
|
|
91
|
-
1.16.6
|