bitcoin2graphdb 0.4.0 → 0.4.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 +4 -4
- data/README.md +25 -1
- data/lib/base.rb +2 -1
- data/lib/bitcoin2graphdb/migration.rb +28 -2
- data/lib/bitcoin2graphdb/version.rb +1 -1
- data/lib/graphdb/model/extensions/open_assets/transaction.rb +6 -5
- data/lib/graphdb/model/extensions/open_assets/tx_out.rb +2 -2
- data/lib/graphdb/model/tx_out.rb +1 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77c42d4d43f05abb3a9f38f21eac5163347176edfc7383c4438c93075bc2586a
|
4
|
+
data.tar.gz: 5a52c195991931f348485de1a9e213dd7cd88c694df504380d669bf753b2a1e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/base.rb
CHANGED
@@ -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 =
|
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?
|
@@ -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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
data/lib/graphdb/model/tx_out.rb
CHANGED
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.
|
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-
|
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.
|
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.
|