bitcoin2graphdb 0.4.0 → 0.4.1

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: 0ac28219e6acc4dd69b308b06455aaf8ff0ec94bf4c3877cc3e44cfcd674948f
4
- data.tar.gz: 8defec9f49d8f193cb56a41f63ea124469fddb1f349e6b833595f735d5a1227a
3
+ metadata.gz: 77c42d4d43f05abb3a9f38f21eac5163347176edfc7383c4438c93075bc2586a
4
+ data.tar.gz: 5a52c195991931f348485de1a9e213dd7cd88c694df504380d669bf753b2a1e2
5
5
  SHA512:
6
- metadata.gz: a66eb8c0226b4e3c4a55ebd5dfb3ff1d7221bab3aa6603119ae0ebe572ce50d028da4bc2f2e4817215a39c4ccbbc144d7a62a16eb8bbaa50ad725b10d387b25c
7
- data.tar.gz: 1ca94b824c0a3f23458dd05bd01ef3d9e40a2a141dd530f0d51131a08896d7ea31193ecd1b9b48d5ac92e46ccbb9a69868061080990d84d13ec96f61a94618dc
6
+ metadata.gz: 7bf099d17a30aa1471cd0d9024e9ab65dcb8c4348ea91079079af35b6495fd656f2d39f1add2c746c450706d7ea0b96ea581f2e0da48e807cad101f5cb6964bd
7
+ data.tar.gz: 555a9b1acee7df09ce2d72e14224850341e0e8dc3705e470d7d1db8f3064f58c3ef9abf01ad367d401521f19b74fab0c079bae9e6ba7505618aa85d941495b2d
data/README.md CHANGED
@@ -25,7 +25,8 @@ Or install it yourself as:
25
25
  This tool requires the following software.
26
26
 
27
27
  * Bitcoin Core
28
- * Neo4j
28
+ * Neo4j (>= 3.0)
29
+ * gem neo4j-core `>= 9.0.0`
29
30
 
30
31
  ## Configuration
31
32
 
@@ -54,6 +55,29 @@ bitcoin2graphdb:
54
55
  open_timeout: 2
55
56
  ```
56
57
 
58
+ You can use bolt protocol if you want more performance.
59
+
60
+ ```yaml
61
+ bitcoin2graphdb:
62
+ bitcoin:
63
+ network: 'mainnet or testnet or regtest'
64
+ rpc:
65
+ user: 'Bitcoin Core rpc user.'
66
+ password: 'Bitcoin Core rpc password.'
67
+ schema: 'Bitcoin Core server schema. ex, http'
68
+ port: 'Bitcoin Core server port. ex, 8332'
69
+ host: 'Bitcoin Core server host. ex, xxx.xxx.xxx.xxx'
70
+ sleep_interval: 600
71
+ min_block_confirmation: 2
72
+ neo4j:
73
+ server: 'neo4j server url. ex, bolt://localhost:7472 or bolt://user:password@localhost:7472'
74
+ options:
75
+ read_timeout: -1 # No timeout. It is blocking mode. Non blocking mode have a problem.
76
+ write_timeout: -1 # No timeout. It is blocking mode. Non blocking mode have a problem.
77
+ connect_timeout: 10
78
+ ssl: false # It is not support SSL yet.
79
+ ```
80
+
57
81
  ## Usage
58
82
 
59
83
  * Show usage
@@ -1,4 +1,5 @@
1
1
  require 'active_support/all'
2
2
  require 'bitcoin2graphdb'
3
3
  require 'graphdb'
4
- require 'neo4j/core/cypher_session/adaptors/http'
4
+ require 'neo4j/core/cypher_session/adaptors/http'
5
+ require 'neo4j/core/cypher_session/adaptors/bolt'
@@ -9,9 +9,8 @@ module Bitcoin2Graphdb
9
9
  c.neo4j_server = config[:neo4j][:server]
10
10
  c.extensions = config[:extensions] unless config[:extensions].nil?
11
11
  end
12
- neo4j_config = {basic_auth: config[:neo4j][:basic_auth], initialize: neo4j_timeout_ops(config)}
13
12
  Bitcoin2Graphdb::Bitcoin.provider = Bitcoin2Graphdb::Bitcoin::BlockchainProvider.new(config[:bitcoin])
14
- neo4j_adaptor = Neo4j::Core::CypherSession::Adaptors::HTTP.new(config[:neo4j][:server], neo4j_config)
13
+ neo4j_adaptor = create_neo4j_adaptor(config)
15
14
  Neo4j::ActiveBase.on_establish_session { Neo4j::Core::CypherSession.new(neo4j_adaptor) }
16
15
  @sleep_interval = config[:bitcoin][:sleep_interval].nil? ? 600 : config[:bitcoin][:sleep_interval].to_i
17
16
 
@@ -140,6 +139,33 @@ module Bitcoin2Graphdb
140
139
  end
141
140
  end
142
141
 
142
+ def create_neo4j_adaptor(config)
143
+ uri = URI(config[:neo4j][:server])
144
+ case uri.scheme
145
+ when 'http'
146
+ faraday_configurator = proc do |faraday|
147
+ require 'typhoeus'
148
+ require 'typhoeus/adapters/faraday'
149
+ faraday.adapter :typhoeus
150
+ faraday.options.merge!(neo4j_timeout_ops(config)[:request])
151
+ end
152
+ neo4j_config = {basic_auth: config[:neo4j][:basic_auth], faraday_configurator: faraday_configurator}
153
+ Neo4j::Core::CypherSession::Adaptors::HTTP.new(config[:neo4j][:server], neo4j_config)
154
+ when 'bolt'
155
+ Neo4j::Core::CypherSession::Adaptors::Bolt.new(config[:neo4j][:server], neo4j_bolt_options(config))
156
+ else
157
+ fail ArgumentError, "Invalid URL: #{uri.inspect}"
158
+ end
159
+ end
160
+
161
+ def neo4j_bolt_options(config)
162
+ if config[:neo4j][:options]
163
+ config[:neo4j][:options]
164
+ else
165
+ { ssl: false }
166
+ end
167
+ end
168
+
143
169
  def asset_outputs(txid)
144
170
  tx = Graphdb::Model::Transaction.with_txid(txid).first
145
171
  not_oa_tx = Bitcoin2Graphdb::Bitcoin.provider.oa_outputs(txid, false).find{|o|!o['asset_id'].nil?}.nil?
@@ -1,3 +1,3 @@
1
1
  module Bitcoin2Graphdb
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -32,11 +32,12 @@ module Graphdb
32
32
 
33
33
  def apply_oa_outputs
34
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
- }
35
+ if oa_outputs.any?{ |tx_out| tx_out['output_type'] == 'marker' }
36
+ oa_outputs.each{|o|
37
+ output = outputs.find_by(n: o['vout'])
38
+ output.apply_oa_attributes(o)
39
+ }
40
+ end
40
41
  end
41
42
 
42
43
  end
@@ -10,8 +10,8 @@ module Graphdb
10
10
 
11
11
  end
12
12
  base.class_eval do
13
- property :asset_quantity, type: Integer
14
- property :oa_output_type
13
+ property :asset_quantity, type: Integer, default: 0
14
+ property :oa_output_type, default: 'uncolored'
15
15
  has_one :out, :asset_id, type: :asset_id, model_class: 'Graphdb::Model::AssetId'
16
16
  end
17
17
  end
@@ -41,9 +41,7 @@ module Graphdb
41
41
  def self.find_by_outpoint(txid, n)
42
42
  tx = Graphdb::Model::Transaction.with_txid(txid).first
43
43
  if tx
44
- tx.outputs.each{|o|
45
- return o if o.n == n
46
- }
44
+ tx.outputs.find_by(n: n)
47
45
  end
48
46
  end
49
47
 
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-15 00:00:00.000000000 Z
11
+ date: 2019-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openassets-ruby
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
- rubygems_version: 2.7.9
224
+ rubygems_version: 2.7.8
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: A tool for import Bitcoin blockchain data into neo4j database.