tapyrus 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44f097dd931371e9cce458e44ff030d9ebedcd9372632339d274457bb3839a4c
4
- data.tar.gz: c72dddb87aacb3f649cc4a542b0988eb54347da6203e0bcc2d430065fc3398b8
3
+ metadata.gz: 9cf211d0ab36f04dbc16d8ee2c60c1f86bc33b5b2d8c68378c7c550e7c0697db
4
+ data.tar.gz: 831801fc796432c6c61ee167dd6acc4778ef49853699babb95614a7765e37fd0
5
5
  SHA512:
6
- metadata.gz: cc7fae61da930e3af35d17039dcd9bda45b6a9317d132dc5096e585ed3b00309a7fc4a3f3552928a57b5b46289bf3fe5be28000cffe666f0d0990480e88b31f3
7
- data.tar.gz: b7d9c26524bda4fe26f4522b51b3328145a6e590a0099f2f72b0d9cbfb43c9a4e9b7ee4eb23907d8d8c8cf3daa239b0b7ad76caee82b5b00edffef63cb69d178
6
+ metadata.gz: 84092b5fd80adc5a7121d3923c9fa4350dde4b271b19df1ed1b39579b0589862087e9c73916650948231c4bd3f1ad9b0d58c38711bad7be2e571466f2f46b2e4
7
+ data.tar.gz: 14389a4e0df4fc5eb78c5ae9c63de6aab4a2a10fe52dcc8e655fe17fa6d6056422c6f0a9233dfc452a14f95480af7081570307124203ec1cbbbb11e77a5731ef
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.3
1
+ 3.0.2
data/lib/tapyrus/key.rb CHANGED
@@ -31,7 +31,7 @@ module Tapyrus
31
31
  # @return [Tapyrus::Key] a key object.
32
32
  def initialize(priv_key: nil, pubkey: nil, key_type: nil, compressed: true, allow_hybrid: false)
33
33
  if key_type.nil? && !compressed.nil? && pubkey.nil?
34
- puts '[Warning] Use key_type parameter instead of compressed. compressed parameter removed in the future.'
34
+ warn('Use key_type parameter instead of compressed. compressed parameter removed in the future.')
35
35
  end
36
36
  if key_type
37
37
  @key_type = key_type
@@ -16,11 +16,14 @@ module Tapyrus
16
16
  nodes = [Node.new(txids.first)]
17
17
  else
18
18
  nodes =
19
- txids.each_slice(2).map do |m|
20
- left = Node.new(m[0])
21
- right = Node.new(m[1] ? m[1] : m[0])
22
- [left, right]
23
- end.flatten
19
+ txids
20
+ .each_slice(2)
21
+ .map do |m|
22
+ left = Node.new(m[0])
23
+ right = Node.new(m[1] ? m[1] : m[0])
24
+ [left, right]
25
+ end
26
+ .flatten
24
27
  end
25
28
  new(build_initial_tree(nodes))
26
29
  end
@@ -26,14 +26,17 @@ module Tapyrus
26
26
 
27
27
  def find_from_dns_seeds
28
28
  logger.debug 'discover peer address from DNS seeds.'
29
- dns_seeds.map do |seed|
30
- begin
31
- Socket.getaddrinfo(seed, Tapyrus.chain_params.default_port).map { |a| a[2] }.uniq
32
- rescue SocketError => e
33
- logger.error "SocketError occurred when load DNS seed: #{seed}, error: #{e.message}"
34
- nil
29
+ dns_seeds
30
+ .map do |seed|
31
+ begin
32
+ Socket.getaddrinfo(seed, Tapyrus.chain_params.default_port).map { |a| a[2] }.uniq
33
+ rescue SocketError => e
34
+ logger.error "SocketError occurred when load DNS seed: #{seed}, error: #{e.message}"
35
+ nil
36
+ end
35
37
  end
36
- end.flatten.compact
38
+ .flatten
39
+ .compact
37
40
  end
38
41
  end
39
42
  end
@@ -281,10 +281,12 @@ module Tapyrus
281
281
  # get public keys in the stack.
282
282
  # @return[Array[String]] an array of the pubkeys with hex format.
283
283
  def get_pubkeys
284
- chunks.select do |c|
285
- c.pushdata? && [33, 65].include?(c.pushed_data.bytesize) &&
286
- [2, 3, 4, 6, 7].include?(c.pushed_data[0].bth.to_i(16))
287
- end.map { |c| c.pushed_data.bth }
284
+ chunks
285
+ .select do |c|
286
+ c.pushdata? && [33, 65].include?(c.pushed_data.bytesize) &&
287
+ [2, 3, 4, 6, 7].include?(c.pushed_data[0].bth.to_i(16))
288
+ end
289
+ .map { |c| c.pushed_data.bth }
288
290
  end
289
291
 
290
292
  # returns the self payload. ScriptInterpreter does not use this.
@@ -349,30 +351,32 @@ module Tapyrus
349
351
  end
350
352
 
351
353
  def to_s
352
- chunks.map do |c|
353
- case c
354
- when Integer
355
- opcode_to_name(c)
356
- when String
357
- return c if c.empty?
358
- if c.pushdata?
359
- v = Opcodes.opcode_to_small_int(c.ord)
360
- if v
361
- v
362
- else
363
- data = c.pushed_data
364
- if data.bytesize <= 4
365
- Script.decode_number(data.bth) # for scriptnum
354
+ chunks
355
+ .map do |c|
356
+ case c
357
+ when Integer
358
+ opcode_to_name(c)
359
+ when String
360
+ return c if c.empty?
361
+ if c.pushdata?
362
+ v = Opcodes.opcode_to_small_int(c.ord)
363
+ if v
364
+ v
366
365
  else
367
- data.bth
366
+ data = c.pushed_data
367
+ if data.bytesize <= 4
368
+ Script.decode_number(data.bth) # for scriptnum
369
+ else
370
+ data.bth
371
+ end
368
372
  end
373
+ else
374
+ opcode = Opcodes.opcode_to_name(c.ord)
375
+ opcode ? opcode : 'OP_UNKNOWN [error]'
369
376
  end
370
- else
371
- opcode = Opcodes.opcode_to_name(c.ord)
372
- opcode ? opcode : 'OP_UNKNOWN [error]'
373
377
  end
374
378
  end
375
- end.join(' ')
379
+ .join(' ')
376
380
  end
377
381
 
378
382
  # generate sha-256 hash for payload
@@ -190,9 +190,15 @@ module Tapyrus
190
190
  shares.each do |share|
191
191
  log_basis_eval = (log_prod - LOG_TABLE[share[0] ^ x] - shares.sum { |s| LOG_TABLE[share[0] ^ s[0]] }) % 255
192
192
  result =
193
- share[1].htb.bytes.each.map.with_index do |v, i|
194
- (result[i].bti ^ (v == 0 ? 0 : (EXP_TABLE[(LOG_TABLE[v] + log_basis_eval) % 255]))).itb
195
- end.join
193
+ share[1]
194
+ .htb
195
+ .bytes
196
+ .each
197
+ .map
198
+ .with_index do |v, i|
199
+ (result[i].bti ^ (v == 0 ? 0 : (EXP_TABLE[(LOG_TABLE[v] + log_basis_eval) % 255]))).itb
200
+ end
201
+ .join
196
202
  end
197
203
  result.bth
198
204
  end
@@ -1,3 +1,3 @@
1
1
  module Tapyrus
2
- VERSION = '0.2.9'
2
+ VERSION = '0.2.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapyrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-21 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa
@@ -425,7 +425,7 @@ homepage: https://github.com/chaintope/tapyrusrb
425
425
  licenses:
426
426
  - MIT
427
427
  metadata: {}
428
- post_install_message:
428
+ post_install_message:
429
429
  rdoc_options: []
430
430
  require_paths:
431
431
  - lib
@@ -440,8 +440,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
440
440
  - !ruby/object:Gem::Version
441
441
  version: '0'
442
442
  requirements: []
443
- rubygems_version: 3.0.3
444
- signing_key:
443
+ rubygems_version: 3.2.22
444
+ signing_key:
445
445
  specification_version: 4
446
446
  summary: The implementation of Tapyrus Protocol for Ruby.
447
447
  test_files: []