coinrpc 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coinrpc/version.rb +1 -1
- data/lib/coinrpc.rb +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f56b954d8a797f018a8451556d8b11cb4a84b62fcb91cc171aca6d542a5c3b8
|
4
|
+
data.tar.gz: 5f7d5e0b3cdfa3eebfaacc8cea3e287dd5087115e0a5587bb2a76a3345e32586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffa84d42cc2dec647fdac362285d4238c1d8541e4bf224f27a2e8b1b32ea971ee5e6b929bf0ed7af049eaa4e42a5b42d5721fb02be41c49f8284c22e43892791
|
7
|
+
data.tar.gz: 9c78993f178ea81eadc004bd489e507856caa7de4c598001a950d4c76e2d2b55afab3d36473d7aba5cf5d5cbdc9dd88dff9345d98a886ec1cf4b14be7f76a25b
|
data/lib/coinrpc/version.rb
CHANGED
data/lib/coinrpc.rb
CHANGED
@@ -4,6 +4,7 @@ require "oj"
|
|
4
4
|
require "json"
|
5
5
|
require "securerandom"
|
6
6
|
require "coinrpc/version"
|
7
|
+
require "set"
|
7
8
|
|
8
9
|
# let OJ mimic JSON
|
9
10
|
Oj.mimic_JSON
|
@@ -19,12 +20,13 @@ module CoinRPC
|
|
19
20
|
JSONRPC_V1_1 = "1.1".freeze
|
20
21
|
JSONRPC_V2_0 = "2.0".freeze
|
21
22
|
TIMEOUT = 60.freeze
|
23
|
+
ENDPOINTS_WITH_ARRAY_ARGS = ['testmempoolaccept'].to_set
|
22
24
|
|
23
25
|
def initialize(url)
|
24
26
|
|
25
27
|
urinfo = URI.parse(url)
|
26
28
|
|
27
|
-
@options = {:timeout => TIMEOUT, :userpwd => "#{urinfo.user}:#{urinfo.password}", :headers => {
|
29
|
+
@options = {:timeout => TIMEOUT, :userpwd => "#{urinfo.user}:#{urinfo.password}", :headers => {'User-Agent' => "CoinRPC/#{CoinRPC::VERSION}"}}.freeze
|
28
30
|
@url = "http://#{urinfo.host}:#{urinfo.port}/".freeze
|
29
31
|
|
30
32
|
end
|
@@ -35,10 +37,10 @@ module CoinRPC
|
|
35
37
|
|
36
38
|
def method_missing(method, *args)
|
37
39
|
|
38
|
-
fixed_method = method.to_s.gsub(/\_/,
|
40
|
+
fixed_method = method.to_s.gsub(/\_/, '').freeze
|
39
41
|
post_data = nil
|
40
42
|
|
41
|
-
if args[0].is_a?(Array) and args[0].size > 0 then
|
43
|
+
if args[0].is_a?(Array) and args[0].size > 0 and !ENDPOINTS_WITH_ARRAY_ARGS.member?(fixed_method) then
|
42
44
|
# batch request
|
43
45
|
post_data = args.map{|arg| {:jsonrpc => JSONRPC_V2_0, :method => fixed_method, :params => arg, :id => random_id} }
|
44
46
|
else
|
@@ -61,13 +63,13 @@ module CoinRPC
|
|
61
63
|
# this won't work without Oj.mimic_JSON
|
62
64
|
result = Oj.strict_load(response.body, :decimal_class => BigDecimal)
|
63
65
|
|
64
|
-
raise result[
|
66
|
+
raise result['error']['message'] if result.is_a?(Hash) and !result['error'].nil?
|
65
67
|
|
66
68
|
if result.is_a?(Hash) then
|
67
|
-
result[
|
69
|
+
result['result']
|
68
70
|
else
|
69
71
|
# batch call
|
70
|
-
result.map{|r| r[
|
72
|
+
result.map!{|r| r['result'] || r['error']}
|
71
73
|
end
|
72
74
|
|
73
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinrpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atif Nazir
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|