Skip to content

Commit 5b5c416

Browse files
committed
update gem versions + use auto SSL/TLS versions + version bump
1 parent fcb71e1 commit 5b5c416

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

block_io.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
2121
spec.add_development_dependency "bundler", "~> 1.6"
2222
spec.add_development_dependency "rake", "~> 0"
2323
spec.add_runtime_dependency "ecdsa", "~> 1.2", '>= 1.2.0'
24-
spec.add_runtime_dependency "httpclient", "~> 2.4", '>= 2.4.0'
25-
spec.add_runtime_dependency "oj"
24+
spec.add_runtime_dependency "httpclient", "~> 2.8", '>= 2.8.0'
25+
spec.add_runtime_dependency "oj", "~> 3.3", '>= 3.3.5'
2626
spec.add_runtime_dependency "oj_mimic_json"
27-
spec.add_runtime_dependency "connection_pool", "~> 2.0", '>= 2.0.0'
27+
spec.add_runtime_dependency "connection_pool", "~> 2.2", '>= 2.2.1'
2828
spec.add_runtime_dependency "pbkdf2-ruby", '~> 0.2', '>= 0.2.1'
2929
end

lib/block_io.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'block_io/version'
22
require 'httpclient'
33
require 'oj'
4-
require 'oj_mimic_json'
54
require 'connection_pool'
65
require 'ecdsa'
76
require 'openssl'
@@ -25,7 +24,7 @@ def self.set_options(args = {})
2524
@pin = args[:pin]
2625
@encryptionKey = Helper.pinToAesKey(@pin) if !@pin.nil?
2726

28-
@conn_pool = ConnectionPool.new(size: 1, timeout: 300) { HTTPClient.new }
27+
@conn_pool = ConnectionPool.new(size: 1, timeout: 300) { h = HTTPClient.new; h.tcp_keepalive = true; h.ssl_config.ssl_version = :auto; h }
2928

3029
@version = args[:version] || 2 # default version is 2
3130

@@ -78,7 +77,7 @@ def self.withdraw(args = {}, method_name = 'withdraw')
7877
Helper.signData(inputs, [key])
7978

8079
# the response object is now signed, let's stringify it and finalize this withdrawal
81-
response = self.api_call(['sign_and_finalize_withdrawal',{:signature_data => response['data'].to_json}])
80+
response = self.api_call(['sign_and_finalize_withdrawal',{:signature_data => Oj.dump(response['data'])}])
8281

8382
# if we provided all the required signatures, this transaction went through
8483
# otherwise Block.io responded with data asking for more signatures
@@ -111,7 +110,7 @@ def self.sweep(args = {}, method_name = 'sweep_from_address')
111110
Helper.signData(inputs, [key])
112111

113112
# the response object is now signed, let's stringify it and finalize this withdrawal
114-
response = self.api_call(['sign_and_finalize_sweep',{:signature_data => response['data'].to_json}])
113+
response = self.api_call(['sign_and_finalize_sweep',{:signature_data => Oj.dump(response['data'])}])
115114

116115
# if we provided all the required signatures, this transaction went through
117116
# otherwise Block.io responded with data asking for more signatures
@@ -132,11 +131,10 @@ def self.api_call(endpoint)
132131
@conn_pool.with do |hc|
133132
# prevent initiation of HTTPClients every time we make this call, use a connection_pool
134133

135-
hc.ssl_config.ssl_version = :TLSv1
136134
response = hc.post("#{@base_url.gsub('API_CALL',endpoint[0]).gsub('VERSION', 'v'+@version.to_s) + @api_key}", endpoint[1])
137135

138136
begin
139-
body = JSON.parse(response.body)
137+
body = Oj.load(response.body)
140138
raise Exception.new(body['data']['error_message']) if !body['status'].eql?('success')
141139
rescue
142140
raise Exception.new('Unknown error occurred. Please report this.')

lib/block_io/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module BlockIo
2-
VERSION = "1.0.7"
2+
VERSION = "1.0.8"
33
end

0 commit comments

Comments
 (0)