bitcoin2graphdb 0.3.3 → 0.3.4

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: 2303b59d58b209277d63533cc25e263c046e8a5a
4
- data.tar.gz: 5b1f7c1f96fe501de34bfcbb0b39206dfc0dae2b
3
+ metadata.gz: ac24982aeb0f636c36886c4129bb9b47073a2074
4
+ data.tar.gz: 776a7afb5c0358738b08613cec44c865b5a037ab
5
5
  SHA512:
6
- metadata.gz: b04cb6d39b86a39cd72dccfb941c93df684eaff531be523046c3ae9efe374e40c9ba65728c7de32814a544e1dfe88d97166e2045416f4fe3e206ba2d3ec7605f
7
- data.tar.gz: de26297d8880a9324c8e4d09421e857471b6aca5cf1098abd6060ef47f94a836e31fcf65a65e97b03ce0ab3285f371d6d2224457a616e8b7f04e8193eca89f97
6
+ metadata.gz: 728557e3109c45e5de06e142edaecab23ebac01e5a884cc68431b059e85ebb3038d447bdb94cb7b74f8079d0654275b5ccc7b76759b39de767d14cfb109ad1c4
7
+ data.tar.gz: f92eb546dd47085e81a1b8f839d77bf9e01756f92ab60b7a38360c544c9b07c3c861f43a45c326f6e779b8cd5f7dd113d0580555185a445c672981a6f6e9504c
data/Rakefile CHANGED
@@ -1,8 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
  require 'base'
4
- load 'neo4j/tasks/neo4j_server.rake'
5
- load 'neo4j/tasks/migration.rake'
4
+ require 'neo4j/rake_tasks'
6
5
  load 'bitcoin2graphdb/tasks/migration.rake'
7
6
 
8
7
  RSpec::Core::RakeTask.new(:spec)
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_runtime_dependency "openassets-ruby", ">= 0.5.1"
23
23
  spec.add_runtime_dependency "daemon-spawn"
24
- spec.add_runtime_dependency 'neo4j', '~> 5.0.0'
24
+ spec.add_runtime_dependency "neo4j", "~>7.1.0"
25
25
  spec.add_runtime_dependency "activesupport", ">= 4.0.2"
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.10"
@@ -33,8 +33,8 @@ module Bitcoin2Graphdb
33
33
  api.provider.getrawtransaction(txid, 1)
34
34
  end
35
35
 
36
- def oa_outputs(txid)
37
- api.get_outputs_from_txid(txid, true)
36
+ def oa_outputs(txid, cache = true)
37
+ api.get_outputs_from_txid(txid, cache)
38
38
  end
39
39
 
40
40
  private
@@ -13,6 +13,8 @@ module Bitcoin2Graphdb
13
13
  Bitcoin2Graphdb::Bitcoin.provider = Bitcoin2Graphdb::Bitcoin::BlockchainProvider.new(config[:bitcoin])
14
14
  Neo4j::Session.open(:server_db, config[:neo4j][:server], neo4j_config)
15
15
  @sleep_interval = config[:bitcoin][:sleep_interval].nil? ? 600 : config[:bitcoin][:sleep_interval].to_i
16
+
17
+ Graphdb::Model.constants.each {|const_name| Graphdb::Model.const_get(const_name)}
16
18
  end
17
19
 
18
20
  def run
@@ -114,6 +116,14 @@ module Bitcoin2Graphdb
114
116
  end
115
117
  end
116
118
 
119
+ def search_invalid_oa_tx
120
+ puts "start get_invalid_oa_tx"
121
+ Graphdb::Model::AssetId.all.each{|asset_id|
122
+ asset_id.issuance_txs.each{|issuance_tx| asset_outputs(issuance_tx.txid)}
123
+ }
124
+ puts "get_invalid_oa_tx end."
125
+ end
126
+
117
127
  private
118
128
  def current_block_height
119
129
  return @block_height if @block_height
@@ -129,5 +139,16 @@ module Bitcoin2Graphdb
129
139
  end
130
140
  end
131
141
 
142
+ def asset_outputs(txid)
143
+ tx = Graphdb::Model::Transaction.with_txid(txid).first
144
+ not_oa_tx = Bitcoin2Graphdb::Bitcoin.provider.oa_outputs(txid, false).find{|o|!o['asset_id'].nil?}.nil?
145
+ tx.outputs.each do |o|
146
+ unless o.asset_id.nil?
147
+ puts "This tx is not oa. txid = #{txid}" if not_oa_tx
148
+ asset_outputs(o.out_point.transaction.txid) unless o.out_point.nil?
149
+ end
150
+ end
151
+ end
152
+
132
153
  end
133
154
  end
@@ -40,6 +40,11 @@ namespace :b2g do
40
40
  end
41
41
  end
42
42
 
43
+ desc 'Search invalid oa tx.(invalid tx exist only openassets-ruby bug.)'
44
+ task :search_invalid_oa_tx, [:config_path] do |task, args|
45
+ get_migration(args.config_path).search_invalid_oa_tx
46
+ end
47
+
43
48
  private
44
49
  def get_migration(config_path)
45
50
  config = YAML.load(File.read(config_path)).deep_symbolize_keys[:bitcoin2graphdb]
@@ -1,3 +1,3 @@
1
1
  module Bitcoin2Graphdb
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -1,9 +1,9 @@
1
1
  module Graphdb
2
2
  module Model
3
3
  class Address < ActiveNodeBase
4
- property :address, index: :exact, constraint: :unique
4
+ property :address, index: :exact
5
5
 
6
- has_many :in, :outputs, origin: :addresses, model_class: TxOut
6
+ has_many :in, :outputs, origin: :addresses, model_class: 'Graphdb::Model::TxOut'
7
7
 
8
8
  validates :address, presence: true
9
9
 
@@ -2,7 +2,7 @@ module Graphdb
2
2
  module Model
3
3
  class Block < ActiveNodeBase
4
4
 
5
- property :block_hash, index: :exact, constraint: :unique
5
+ property :block_hash, index: :exact
6
6
  property :size, type: Integer
7
7
  property :height, type: Integer
8
8
  property :version
@@ -18,8 +18,8 @@ module Graphdb
18
18
  property :created_at
19
19
  property :updated_at
20
20
 
21
- has_many :in, :transactions, origin: :block, model_class: Transaction, dependent: :destroy
22
- has_one :out, :previous_block, type: :previous_block, model_class: Block
21
+ has_many :in, :transactions, origin: :block, model_class: 'Graphdb::Model::Transaction', dependent: :destroy
22
+ has_one :out, :previous_block, type: :previous_block, model_class: 'Graphdb::Model::Block'
23
23
 
24
24
  validates :block_hash, :presence => true
25
25
  validates :height, :presence => true
@@ -2,9 +2,9 @@ module Graphdb
2
2
  module Model
3
3
 
4
4
  class AssetId < ActiveNodeBase
5
- property :asset_id, index: :exact, constraint: :unique
5
+ property :asset_id, index: :exact
6
6
 
7
- has_many :in, :outputs, origin: :asset_id, model_class: TxOut
7
+ has_many :in, :outputs, origin: :asset_id, model_class: 'Graphdb::Model::TxOut'
8
8
 
9
9
  validates :asset_id, :presence => true
10
10
 
@@ -15,12 +15,7 @@ module Graphdb
15
15
 
16
16
  def create_from_txid(txid)
17
17
  tx = super(txid)
18
- outputs = Bitcoin2Graphdb::Bitcoin.provider.oa_outputs(txid)
19
- graph_outputs = tx.outputs.to_a
20
- outputs.each{|o|
21
- output = graph_outputs.find{|graph_out|graph_out.n == o['vout']}
22
- output.apply_oa_attributes(o)
23
- }
18
+ tx.apply_oa_outputs
24
19
  tx.save!
25
20
  tx
26
21
  end
@@ -35,6 +30,15 @@ module Graphdb
35
30
  false
36
31
  end
37
32
 
33
+ def apply_oa_outputs
34
+ oa_outputs = Bitcoin2Graphdb::Bitcoin.provider.oa_outputs(txid)
35
+ graph_outputs = outputs.to_a
36
+ oa_outputs.each{|o|
37
+ output = graph_outputs.find{|graph_out|graph_out.n == o['vout']}
38
+ output.apply_oa_attributes(o)
39
+ }
40
+ end
41
+
38
42
  end
39
43
 
40
44
  end
@@ -12,7 +12,7 @@ module Graphdb
12
12
  base.class_eval do
13
13
  property :asset_quantity, type: Integer
14
14
  property :oa_output_type
15
- has_one :out, :asset_id, type: :asset_id, model_class: AssetId
15
+ has_one :out, :asset_id, type: :asset_id, model_class: 'Graphdb::Model::AssetId'
16
16
  end
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ module Graphdb
23
23
  def apply_oa_attributes(oa_out)
24
24
  self.asset_quantity = oa_out['asset_quantity']
25
25
  self.oa_output_type = oa_out['output_type']
26
- self.asset_id = AssetId.find_or_create(oa_out['asset_id']) unless oa_out['asset_id'].nil?
26
+ self.asset_id = oa_out['asset_id'].nil? ? nil : AssetId.find_or_create(oa_out['asset_id'])
27
27
  self.oa_output_type = 'uncolored' if self.asset_id.nil? && self.oa_output_type != 'marker'
28
28
  save!
29
29
  end
@@ -3,7 +3,7 @@ module Graphdb
3
3
  class Transaction < ActiveNodeBase
4
4
 
5
5
  property :hex
6
- property :txid, index: :exact, constraint: :unique
6
+ property :txid, index: :exact
7
7
  property :version, type: Integer
8
8
  property :lock_time
9
9
  property :block_hash
@@ -12,8 +12,8 @@ module Graphdb
12
12
  property :confirmations, type: Integer
13
13
 
14
14
  has_one :out, :block, type: :block
15
- has_many :in, :inputs, origin: :transaction, model_class: TxIn, dependent: :destroy
16
- has_many :in, :outputs, origin: :transaction, model_class: TxOut, dependent: :destroy
15
+ has_many :in, :inputs, origin: :transaction, model_class: 'Graphdb::Model::TxIn', dependent: :destroy
16
+ has_many :in, :outputs, origin: :transaction, model_class: 'Graphdb::Model::TxOut', dependent: :destroy
17
17
 
18
18
  validates :hex, :presence => true
19
19
  validates :txid, :presence => true
@@ -9,8 +9,8 @@ module Graphdb
9
9
  property :coinbase
10
10
  property :sequence
11
11
 
12
- has_one :out, :transaction, type: :transaction, model_class: Transaction
13
- has_one :in, :out_point, origin: :out_point, model_class: Graphdb::Model::TxOut
12
+ has_one :out, :transaction, type: :transaction, model_class: 'Graphdb::Model::Transaction'
13
+ has_one :in, :out_point, origin: :out_point, model_class: 'Graphdb::Model::TxOut'
14
14
 
15
15
  validates :sequence, :presence => true
16
16
 
@@ -9,9 +9,9 @@ module Graphdb
9
9
  property :output_type
10
10
  property :req_sigs, type: Integer
11
11
 
12
- has_one :out, :transaction, type: :transaction, model_class: Transaction
13
- has_many :out, :addresses, type: :address, model_class: Address
14
- has_one :out, :out_point, type: :spent_input, model_class: TxIn
12
+ has_one :out, :transaction, type: :transaction, model_class: 'Graphdb::Model::Transaction'
13
+ has_many :out, :addresses, type: :address, model_class: 'Graphdb::Model::Address'
14
+ has_one :out, :out_point, type: :spent_input, model_class: 'Graphdb::Model::TxIn'
15
15
 
16
16
  validates :value, :presence => true
17
17
  validates :n, :presence => true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitcoin2graphdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openassets-ruby
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 5.0.0
47
+ version: 7.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 5.0.0
54
+ version: 7.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement