radiator 0.2.1 → 0.2.2a

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48d78f3aecd0d6dab2141d2e8eec45594864a651
4
- data.tar.gz: 6772482fe30e9cf8da78390fb869e5948d1219fb
3
+ metadata.gz: 4d1f4ab74ac8b1297212941aaf9a80e003e26c61
4
+ data.tar.gz: 99be65977b3d04ba23704f5d4837ca66cff94c52
5
5
  SHA512:
6
- metadata.gz: fbb8ca75dae837973b8c06a92e3f4b41c2b752492719acea746a52f7668a6e9f1545ba1693ebd5a36bafb6a7b0f253be8b77312c0bd3e0af01cc970aa1651f7a
7
- data.tar.gz: 811b1efb6ec7ab45ced3feb40a95ccd5ebd11c6cce73e47cd749085d05c0a8d6188ede17889e48eeca68f27f9ce34bc0407555b5efbb383666ba2712a083afac
6
+ metadata.gz: 9187e47986973e23d415f06254ec196df11416d5e725628e2207e878595cf70267ee92a0f4bb4b0f8ef6aa241d140de017a6a3bf0b29e01f0d49b18bc348d562
7
+ data.tar.gz: 11abfb49f5382821791a847ca15fc00fd18d56577e3138d0772cfc492ddd7a24e16fb9174495cf6cd729d2af5974a563111163c37bce9463d5083a631ba47058
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- radiator (0.2.1)
4
+ radiator (0.2.2a)
5
5
  bitcoin-ruby (= 0.0.10)
6
- ffi (= 1.9.17)
6
+ ffi (= 1.9.18)
7
7
  hashie (~> 3.5, >= 3.5.5)
8
8
  json (~> 1.8, >= 1.8.6)
9
9
  logging (~> 2.2, >= 2.2.0)
@@ -26,8 +26,8 @@ GEM
26
26
  ffi (>= 1.3.0)
27
27
  faraday (0.9.2)
28
28
  multipart-post (>= 1.2, < 3)
29
- ffi (1.9.17)
30
- hashdiff (0.3.2)
29
+ ffi (1.9.18)
30
+ hashdiff (0.3.4)
31
31
  hashie (3.5.5)
32
32
  json (1.8.6)
33
33
  little-plugger (1.1.4)
@@ -35,7 +35,7 @@ GEM
35
35
  little-plugger (~> 1.1)
36
36
  multi_json (~> 1.10)
37
37
  method_source (0.8.2)
38
- minitest (5.10.1)
38
+ minitest (5.10.2)
39
39
  minitest-line (0.6.3)
40
40
  minitest (~> 5.0)
41
41
  multi_json (1.12.1)
data/README.md CHANGED
@@ -9,15 +9,14 @@
9
9
 
10
10
  Radiator is an API Client for interaction with the STEEM network using Ruby.
11
11
 
12
- #### Fixes in v0.2.0
12
+ #### Fixes in v0.2.2
13
13
 
14
- * Updated to support all new methods in HF18.
15
- * Improved streaming reliability: added max blocks per node (default 100).
16
14
  * Gem updates
17
- * corrected pessimistic dependencies
18
- * development/testing
19
- * windows related compatibility
20
- * Fixed support for array (set) parameters in broadcast operations.
15
+ * Improved support for datatypes and handlers.
16
+ * UTF-8 handled more smoothly.
17
+ * Simplified operation construction.
18
+ * Improved keep-alive defaults.
19
+ * Better streaming reliability.
21
20
 
22
21
  ---
23
22
 
@@ -271,8 +270,7 @@ vote = {
271
270
  weight: 10000
272
271
  }
273
272
 
274
- op = Radiator::Operation.new(vote)
275
- tx.operations << op
273
+ tx.operations << vote
276
274
  tx.process(true)
277
275
  ```
278
276
 
@@ -291,8 +289,7 @@ comment = {
291
289
  parent_author: ''
292
290
  }
293
291
 
294
- op = Radiator::Operation.new(comment)
295
- tx.operations << op
292
+ tx.operations << comment
296
293
  tx.process(true)
297
294
  ```
298
295
 
@@ -308,8 +305,7 @@ transfer = {
308
305
  memo: 'Wow, inertia! Radiator is great!'
309
306
  }
310
307
 
311
- op = Radiator::Operation.new(comment)
312
- tx.operations << op
308
+ tx.operations << transfer
313
309
  tx.process(true)
314
310
  ```
315
311
 
@@ -327,8 +323,7 @@ vote = {
327
323
  weight: 10000
328
324
  }
329
325
 
330
- op = Radiator::Operation.new(vote)
331
- tx.operations << op
326
+ tx.operations << vote
332
327
  tx.process(true)
333
328
  ```
334
329
 
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ gource ./ --user-image-dir ~/Desktop --hide usernames -s 0.5 -b 000000 \
4
+ -1280x720 --output-ppm-stream - |\
5
+ ffmpeg -y -r 28 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset slow \
6
+ -crf 28 -threads 0 output.mp4
@@ -2,13 +2,17 @@ require 'radiator/version'
2
2
  require 'json'
3
3
 
4
4
  module Radiator
5
+ require 'radiator/utils'
6
+ require 'radiator/type/serializer'
5
7
  require 'radiator/type/amount'
6
8
  require 'radiator/type/u_int16'
7
9
  require 'radiator/type/u_int32'
8
10
  require 'radiator/type/point_in_time'
9
11
  require 'radiator/type/permission'
10
12
  require 'radiator/type/public_key'
11
- require 'radiator/utils'
13
+ require 'radiator/type/beneficiaries'
14
+ require 'radiator/type/price'
15
+ require 'radiator/type/future'
12
16
  require 'radiator/logger'
13
17
  require 'radiator/chain_config'
14
18
  require 'radiator/api'
@@ -57,9 +57,9 @@ module Radiator
57
57
  # @return [Hash]
58
58
  def find_block(block_number, &block)
59
59
  if !!block
60
- yield get_blocks(block_number).result
60
+ yield get_blocks(block_number).first
61
61
  else
62
- get_blocks(block_number).result
62
+ get_blocks(block_number).first
63
63
  end
64
64
  end
65
65
 
@@ -143,7 +143,13 @@ module Radiator
143
143
  end
144
144
 
145
145
  def http
146
- @http ||= Net::HTTP::Persistent.new "radiator-#{Radiator::VERSION}-#{self.class.name.downcase}"
146
+ @http_id ||= "radiator-#{Radiator::VERSION}-#{self.class.name.downcase}"
147
+ @http ||= Net::HTTP::Persistent.new(@http_id).tap do |http|
148
+ http.retry_change_requests = true
149
+ http.max_requests = 30
150
+ http.read_timeout = 10
151
+ http.open_timeout = 10
152
+ end
147
153
  end
148
154
 
149
155
  def request(options)
@@ -152,13 +158,16 @@ module Radiator
152
158
  request = Net::HTTP::Post.new uri.request_uri, 'Content-Type' => 'application/json'
153
159
  request.body = JSON[options]
154
160
  return http.request(uri, request)
155
- rescue Net::HTTP::Persistent::Error
161
+ rescue Net::HTTP::Persistent::Error => e
162
+ @logger.warn "Unable to perform request: #{request} :: #{e}: #{e.backtrace}"
156
163
  @net_http_persistent_enabled = false
157
164
  end
158
165
  end
159
166
 
160
167
  unless @net_http_persistent_enabled
161
168
  @http = Net::HTTP.new(uri.host, uri.port)
169
+ @http.use_ssl = true
170
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
162
171
  request = Net::HTTP::Post.new uri.request_uri, 'Content-Type' => 'application/json'
163
172
  request.body = JSON[options]
164
173
  @http.request(request)
@@ -196,6 +196,7 @@
196
196
  "permlink",
197
197
  "max_accepted_payout",
198
198
  "percent_steem_dollars",
199
+ "allow_replies",
199
200
  "allow_votes",
200
201
  "allow_curation_rewards",
201
202
  "extensions"
@@ -6,7 +6,7 @@ module Radiator
6
6
 
7
7
  def initialize(options = {})
8
8
  options.each do |k, v|
9
- instance_variable_set("@#{k}", v)
9
+ instance_variable_set("@#{k}", type(@type, k, v))
10
10
  end
11
11
 
12
12
  unless Operation::known_operation_names.include? @type
@@ -21,16 +21,16 @@ module Radiator
21
21
  next unless defined? p
22
22
 
23
23
  v = instance_variable_get("@#{p}")
24
- v = type(@type, p, v)
25
-
26
24
  bytes += v.to_bytes and next if v.respond_to? :to_bytes
27
25
 
28
26
  bytes += case v
27
+ when Symbol then pakStr(v.to_s)
29
28
  when String then pakStr(v)
30
29
  when Integer then paks(v)
31
30
  when TrueClass then pakC(1)
32
31
  when FalseClass then pakC(0)
33
32
  when Array then pakArr(v)
33
+ when Hash then pakHash(v)
34
34
  when NilClass then next
35
35
  else
36
36
  raise OperationError, "Unsupported type: #{v.class}"
@@ -46,7 +46,14 @@ module Radiator
46
46
  Operation::param_names(@type.to_sym).each do |p|
47
47
  next unless defined? p
48
48
 
49
- params[p] = instance_variable_get("@#{p}")
49
+ v = instance_variable_get("@#{p}")
50
+ next if v.nil?
51
+ next if v.class == Radiator::Type::Future
52
+
53
+ params[p] = case v
54
+ when Radiator::Type::Beneficiaries then [[0, v.to_h]]
55
+ else; v
56
+ end
50
57
  end
51
58
 
52
59
  [@type, params]
@@ -21,6 +21,9 @@ module Radiator
21
21
  limit_order_cancel: {
22
22
  orderid: Type::Uint32
23
23
  },
24
+ feed_publish: {
25
+ exchange_rate: Type::Price
26
+ },
24
27
  convert: {
25
28
  requestid: Type::Uint32,
26
29
  amount: Type::Amount
@@ -42,11 +45,18 @@ module Radiator
42
45
  id: Type::Uint16
43
46
  },
44
47
  comment_options: {
45
- max_accepted_payout: Type::Amount
48
+ max_accepted_payout: Type::Amount,
49
+ allow_replies: Type::Future
46
50
  },
47
51
  set_withdraw_vesting_route: {
48
52
  percent: Type::Uint16
49
53
  },
54
+ limit_order_create2: {
55
+ orderid: Type::Uint32,
56
+ amount_to_sell: Type::Amount,
57
+ exchange_rate: Type::Price,
58
+ expiration: Type::PointInTime
59
+ },
50
60
  request_account_recovery: {
51
61
  new_owner_Permission: Type::Permission
52
62
  },
@@ -84,7 +94,7 @@ module Radiator
84
94
  request_id: Type::Uint32
85
95
  },
86
96
  reset_account: {
87
- new_owner_Permission: Type::Amount
97
+ new_owner_permission: Type::Amount
88
98
  },
89
99
  set_reset_account: {
90
100
  reward_steem: Type::Amount,
@@ -74,18 +74,27 @@ module Radiator
74
74
  self
75
75
  end
76
76
  end
77
+
78
+ def operations
79
+ @operations = @operations.map do |op|
80
+ case op
81
+ when Operation then op
82
+ else; Operation.new(op)
83
+ end
84
+ end
85
+ end
77
86
  private
78
87
  def payload
79
88
  {
80
89
  expiration: @expiration.strftime('%Y-%m-%dT%H:%M:%S'),
81
90
  ref_block_num: @ref_block_num,
82
91
  ref_block_prefix: @ref_block_prefix,
83
- operations: @operations.map { |op| op.payload },
92
+ operations: operations.map { |op| op.payload },
84
93
  extensions: [],
85
94
  signatures: [hexlify(signature)]
86
95
  }
87
96
  end
88
-
97
+
89
98
  def prepare
90
99
  raise TransactionError, "No wif or private key." unless !!@wif || !!@private_key
91
100
 
@@ -98,13 +107,6 @@ module Radiator
98
107
  # time + EXPIRE_IN_SECS.
99
108
  @expiration = Time.parse(@properties.time + 'Z') + EXPIRE_IN_SECS
100
109
 
101
- @operations = @operations.map do |op|
102
- case op
103
- when Operation then op
104
- else; Operation.new(op)
105
- end
106
- end
107
-
108
110
  self
109
111
  end
110
112
 
@@ -113,9 +115,9 @@ module Radiator
113
115
  bytes << pakS(@ref_block_num)
114
116
  bytes << pakI(@ref_block_prefix)
115
117
  bytes << pakI(@expiration.to_i)
116
- bytes << pakC(@operations.size)
118
+ bytes << pakC(operations.size)
117
119
 
118
- @operations.each do |op|
120
+ operations.each do |op|
119
121
  bytes << op.to_bytes
120
122
  end
121
123
 
@@ -2,9 +2,11 @@ module Radiator
2
2
  module Type
3
3
 
4
4
  # See: https://github.com/xeroc/piston-lib/blob/34a7525cee119ec9b24a99577ede2d54466fca0e/steembase/operations.py
5
- class Amount
5
+ class Amount < Serializer
6
6
  def initialize(value)
7
- @amount, @asset = value.strip.split(' ')
7
+ super(:amount, value)
8
+
9
+ @amount, @asset = @value.strip.split(' ')
8
10
  @precision = case @asset
9
11
  when 'STEEM' then 3
10
12
  when 'VESTS' then 6
@@ -0,0 +1,29 @@
1
+ module Radiator
2
+ module Type
3
+ class Beneficiaries < Serializer
4
+
5
+ def initialize(value)
6
+ super(:beneficiaries, value)
7
+ end
8
+
9
+ def to_bytes
10
+ pakArr([]) + pakHash(@value)
11
+ end
12
+
13
+ def to_h
14
+ v = @value.map do |b|
15
+ case b
16
+ when Array then {account: b.first, weight: b.last}
17
+ else; {account: b.keys.first, weight: b.values.first}
18
+ end
19
+ end
20
+
21
+ {@key => v}
22
+ end
23
+
24
+ def to_s
25
+ to_h.to_json
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ module Radiator
2
+ module Type
3
+
4
+ # See: https://github.com/xeroc/piston-lib/blob/34a7525cee119ec9b24a99577ede2d54466fca0e/steembase/operations.py
5
+ class Future < Serializer
6
+ def initialize(value)
7
+ super(:future, true)
8
+ end
9
+
10
+ def to_bytes
11
+ [1].pack('U')
12
+ end
13
+
14
+ def to_s
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,8 +2,9 @@ module Radiator
2
2
  module Type
3
3
 
4
4
  # See: https://github.com/xeroc/piston-lib/blob/34a7525cee119ec9b24a99577ede2d54466fca0e/steembase/operations.py
5
- class Permission
6
- def initialize()
5
+ class Permission < Serializer
6
+ def initialize(value)
7
+ super(:permission, value)
7
8
  raise NotImplementedError, 'stub'
8
9
  end
9
10
 
@@ -2,9 +2,9 @@ module Radiator
2
2
  module Type
3
3
 
4
4
  # See: https://github.com/xeroc/python-graphenelib/blob/98de98e219264d45fe04b3c28f3aabd1a9f58b71/graphenebase/types.py
5
- class PointInTime
5
+ class PointInTime < Serializer
6
6
  def initialize(value)
7
- @value = value
7
+ super(:point_in_time, value)
8
8
  end
9
9
 
10
10
  def to_bytes
@@ -0,0 +1,25 @@
1
+ module Radiator
2
+ module Type
3
+ class Price < Serializer
4
+
5
+ def initialize(value)
6
+ super(:price, value)
7
+
8
+ @base = Amount.new(@value[:base])
9
+ @quote = Amount.new(@value[:quote])
10
+ end
11
+
12
+ def to_bytes
13
+ @base.to_bytes + @quote.to_bytes
14
+ end
15
+
16
+ def to_h
17
+ {@key => {base: @base, quote: @quote}}
18
+ end
19
+
20
+ def to_s
21
+ to_h.to_json
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,8 +2,9 @@ module Radiator
2
2
  module Type
3
3
 
4
4
  # See: https://github.com/xeroc/piston-lib/blob/34a7525cee119ec9b24a99577ede2d54466fca0e/steembase/operations.py
5
- class PublicKey
6
- def initialize()
5
+ class PublicKey < Serializer
6
+ def initialize(value)
7
+ super(:public_key, value)
7
8
  raise NotImplementedError, 'stub'
8
9
  end
9
10
 
@@ -0,0 +1,12 @@
1
+ module Radiator
2
+ module Type
3
+ class Serializer
4
+ include Radiator::Utils
5
+
6
+ def initialize(key, value)
7
+ @key = key
8
+ @value = value
9
+ end
10
+ end
11
+ end
12
+ end
@@ -2,9 +2,9 @@ module Radiator
2
2
  module Type
3
3
 
4
4
  # See: https://github.com/xeroc/piston-lib/blob/34a7525cee119ec9b24a99577ede2d54466fca0e/steembase/operations.py
5
- class Uint16
5
+ class Uint16 < Serializer
6
6
  def initialize(value)
7
- @value = value.to_i
7
+ super(:u_int_16, value.to_i)
8
8
  end
9
9
 
10
10
  def to_bytes
@@ -2,9 +2,9 @@ module Radiator
2
2
  module Type
3
3
 
4
4
  # See: https://github.com/xeroc/piston-lib/blob/34a7525cee119ec9b24a99577ede2d54466fca0e/steembase/operations.py
5
- class Uint32
5
+ class Uint32 < Serializer
6
6
  def initialize(value)
7
- @value = value.to_i
7
+ super(:u_int_32, value.to_i)
8
8
  end
9
9
 
10
10
  def to_bytes
@@ -28,11 +28,46 @@ module Radiator
28
28
  end
29
29
 
30
30
  def pakStr(s)
31
- varint(s.size) + s
31
+ s = s.dup.force_encoding('BINARY')
32
+ bytes = []
33
+ bytes << varint(s.size)
34
+ bytes << s
35
+
36
+ bytes.join
32
37
  end
33
38
 
34
39
  def pakArr(a)
35
- varint(a.size) + a.map { |v| pakStr(v) }.join
40
+ varint(a.size) + a.map do |v|
41
+ case v
42
+ when Symbol then pakStr(v.to_s)
43
+ when String then pakStr(v)
44
+ when Integer then paks(v)
45
+ when TrueClass then pakC(1)
46
+ when FalseClass then pakC(0)
47
+ when Array then pakArr(v)
48
+ when Hash then pakHash(v)
49
+ when NilClass then next
50
+ else
51
+ raise OperationError, "Unsupported type: #{v.class}"
52
+ end
53
+ end.join
54
+ end
55
+
56
+ def pakHash(h)
57
+ varint(h.size) + h.map do |k, v|
58
+ pakStr(k.to_s) + case v
59
+ when Symbol then pakStr(v.to_s)
60
+ when String then pakStr(v)
61
+ when Integer then paks(v)
62
+ when TrueClass then pakC(1)
63
+ when FalseClass then pakC(0)
64
+ when Array then pakArr(v)
65
+ when Hash then pakHash(v)
66
+ when NilClass then next
67
+ else
68
+ raise OperationError, "Unsupported type: #{v.class}"
69
+ end
70
+ end.join
36
71
  end
37
72
 
38
73
  def pakC(i)
@@ -1,3 +1,3 @@
1
1
  module Radiator
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2a'
3
3
  end
@@ -38,5 +38,5 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency('logging', '~> 2.2', '>= 2.2.0')
39
39
  spec.add_dependency('hashie', '~> 3.5', '>= 3.5.5')
40
40
  spec.add_dependency('bitcoin-ruby', '0.0.10')
41
- spec.add_dependency('ffi', '1.9.17')
41
+ spec.add_dependency('ffi', '1.9.18')
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2a
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -334,14 +334,14 @@ dependencies:
334
334
  requirements:
335
335
  - - '='
336
336
  - !ruby/object:Gem::Version
337
- version: 1.9.17
337
+ version: 1.9.18
338
338
  type: :runtime
339
339
  prerelease: false
340
340
  version_requirements: !ruby/object:Gem::Requirement
341
341
  requirements:
342
342
  - - '='
343
343
  - !ruby/object:Gem::Version
344
- version: 1.9.17
344
+ version: 1.9.18
345
345
  description: Client for accessing the STEEM blockchain.
346
346
  email:
347
347
  - radiator@martin-studio.com
@@ -357,6 +357,7 @@ files:
357
357
  - LICENSE
358
358
  - README.md
359
359
  - Rakefile
360
+ - gource.sh
360
361
  - lib/radiator.rb
361
362
  - lib/radiator/account_by_key_api.rb
362
363
  - lib/radiator/api.rb
@@ -377,9 +378,13 @@ files:
377
378
  - lib/radiator/tag_api.rb
378
379
  - lib/radiator/transaction.rb
379
380
  - lib/radiator/type/amount.rb
381
+ - lib/radiator/type/beneficiaries.rb
382
+ - lib/radiator/type/future.rb
380
383
  - lib/radiator/type/permission.rb
381
384
  - lib/radiator/type/point_in_time.rb
385
+ - lib/radiator/type/price.rb
382
386
  - lib/radiator/type/public_key.rb
387
+ - lib/radiator/type/serializer.rb
383
388
  - lib/radiator/type/u_int16.rb
384
389
  - lib/radiator/type/u_int32.rb
385
390
  - lib/radiator/utils.rb
@@ -400,9 +405,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
400
405
  version: '0'
401
406
  required_rubygems_version: !ruby/object:Gem::Requirement
402
407
  requirements:
403
- - - ">="
408
+ - - ">"
404
409
  - !ruby/object:Gem::Version
405
- version: '0'
410
+ version: 1.3.1
406
411
  requirements: []
407
412
  rubyforge_project:
408
413
  rubygems_version: 2.4.8