openassets-ruby 0.2.0 → 0.2.1

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: ad9b917508f6d470f30b887f8ae9d5cce02fdc0a
4
- data.tar.gz: b88e61903d84a5e05ff1e39eca558a73bb65df49
3
+ metadata.gz: 3d8052b1dcdf76bb4c36271aa86d543135b110b6
4
+ data.tar.gz: 0300e7f511a0365192bcc3138dea33510d0dcdf1
5
5
  SHA512:
6
- metadata.gz: 385715ff6acdfa617eee821e57b6ab74d63bb896f0566af31319ec81c87eecb3f8786bc96178c41f8dc533dc2623b82598a13729986453be574b19b46d932a14
7
- data.tar.gz: 31ab11d1390551dcfcc5d214f69e068220c494a1782d6a470c7ac9d390931425953d38b47327d319183161a8f5efc436b32a85e0ca6623a89dc0a73240c6bcfc
6
+ metadata.gz: 1eb24f346b31042c16065aaed4224bc548cc3b5da06b73e7b4bda240783a772fbfd13ae8383cc096d2324e5c927f2b365813286a6225d7d1e7a29aca1dfa6bfc
7
+ data.tar.gz: cc4c9597c8b4d0b70108334ada063ac3142a91e9ea29d3ccb7f723fb4273f07844d667f1d54534e9a8218af2222bb0bfef87d5a155624fd3716be33693382e19
@@ -3,6 +3,7 @@ module OpenAssets
3
3
 
4
4
  # Represents a transaction output and its asset ID and asset quantity.
5
5
  class TransactionOutput
6
+
6
7
  attr_accessor :value
7
8
  attr_accessor :script
8
9
  attr_accessor :asset_id
@@ -45,13 +46,16 @@ module OpenAssets
45
46
  @asset_definition.divisibility
46
47
  end
47
48
 
48
- # get Asset definition url that is included metadata.
49
49
  private
50
+
51
+ @@definition_cache = {}
52
+
53
+ # get Asset definition url that is included metadata.
50
54
  def load_asset_definition_url
51
55
  @asset_definition_url = ''
52
56
  return if @metadata.nil? || @metadata.length == 0
53
57
  if @metadata.start_with?('u=')
54
- @asset_definition = AssetDefinition.parse_url(metadata_url)
58
+ @asset_definition = load_asset_definition(metadata_url)
55
59
  if valid_asset_definition?
56
60
  @asset_definition_url = metadata_url
57
61
  else
@@ -62,8 +66,6 @@ module OpenAssets
62
66
  end
63
67
  end
64
68
 
65
- private
66
-
67
69
  def metadata_url
68
70
  unless @metadata.nil?
69
71
  @metadata.slice(2..-1)
@@ -73,6 +75,11 @@ module OpenAssets
73
75
  def valid_asset_definition?
74
76
  !@asset_definition.nil? && @asset_definition.include_asset_id?(@asset_id)
75
77
  end
78
+
79
+ def load_asset_definition(url)
80
+ @@definition_cache[url] = AssetDefinition.parse_url(metadata_url) unless @@definition_cache.has_key?(url)
81
+ @@definition_cache[url]
82
+ end
76
83
  end
77
84
 
78
85
  end
@@ -66,8 +66,7 @@ module OpenAssets
66
66
  def self.collect_uncolored_outputs(unspent_outputs, amount)
67
67
  total_amount = 0
68
68
  results = []
69
- sorted_outputs = unspent_outputs.sort{|a,b| a.output.value <=> b.output.value}
70
- sorted_outputs.each do |output|
69
+ unspent_outputs.each do |output|
71
70
  if output.output.asset_id.nil?
72
71
  results << output
73
72
  total_amount += output.output.value
@@ -1,3 +1,3 @@
1
1
  module OpenAssets
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openassets-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bitcoin-ruby