bitcoin2graphdb 0.3.9 → 0.4.0

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
- SHA1:
3
- metadata.gz: 702d79fd9fb47f7ffd16523a876f9d84462cebe9
4
- data.tar.gz: c37d187e40612777ee4078aa4065619a58dc7a4a
2
+ SHA256:
3
+ metadata.gz: 0ac28219e6acc4dd69b308b06455aaf8ff0ec94bf4c3877cc3e44cfcd674948f
4
+ data.tar.gz: 8defec9f49d8f193cb56a41f63ea124469fddb1f349e6b833595f735d5a1227a
5
5
  SHA512:
6
- metadata.gz: 5e77036ba699a9147125077510d060c68b0bb33425e4998a7355e7dff81466e5ebda63e1ad08402eab4baf708d2f9d4f127344746ea9454ab7729545bc7268a8
7
- data.tar.gz: 168b34282906e0fcc83bce76208f6640a33b34a0c6138f75d8f69614d6bbc82f417ff15ab769774ec3349136cc90095ebfff25eab7edf91028e1e2d4100e9f5f
6
+ metadata.gz: a66eb8c0226b4e3c4a55ebd5dfb3ff1d7221bab3aa6603119ae0ebe572ce50d028da4bc2f2e4817215a39c4ccbbc144d7a62a16eb8bbaa50ad725b10d387b25c
7
+ data.tar.gz: 1ca94b824c0a3f23458dd05bd01ef3d9e40a2a141dd530f0d51131a08896d7ea31193ecd1b9b48d5ac92e46ccbb9a69868061080990d84d13ec96f61a94618dc
data/.gitignore CHANGED
@@ -11,6 +11,8 @@
11
11
  .idea
12
12
  config.yml
13
13
  cache.db
14
- db/neo4j
14
+ db/neo4j/*
15
+ !db/neo4j/migrate
16
+ !db/neo4j/schema.yml
15
17
  bitcoin2graphdb.log
16
18
  bitcoin2graphdb.pid
data/.travis.yml CHANGED
@@ -7,9 +7,15 @@ rvm:
7
7
  bundler_args: --jobs=2
8
8
 
9
9
  before_script:
10
- - bundle exec rake neo4j:install[community-2.3.3,test]
10
+ - bundle exec rake neo4j:install[community-3.4.1,test]
11
11
  - bundle exec rake neo4j:config[test,7475]
12
12
  - bundle exec rake neo4j:start[test]
13
+ - sleep 20
14
+ - bundle exec rake neo4j:migrate
15
+
16
+ env:
17
+ global:
18
+ - NEO4J_URL="http://localhost:7475"
13
19
 
14
20
  script:
15
21
  - bundle exec rake spec
data/README.md CHANGED
@@ -109,7 +109,7 @@ Others are the same as normal rspec.
109
109
  ### install test database
110
110
 
111
111
  ```
112
- $ rake neo4j:install'[community-2.3.3,test]'
112
+ $ rake neo4j:install'[community-3.4.1,test]'
113
113
  ```
114
114
 
115
115
  ### change port
@@ -124,6 +124,16 @@ $ rake neo4j:config'[test,7475]'
124
124
  $ rake neo4j:start'[test]'
125
125
  ```
126
126
 
127
+ ### migration
128
+ ```
129
+ $ rake neo4j:migrate
130
+ ```
131
+
132
+ #### specify neo4j url (optional)
133
+ ```
134
+ $ rake neo4j:migrate NEO4J_URL=http://localhost:7475
135
+ ```
136
+
127
137
  ## Contributing
128
138
 
129
139
  Bug reports and pull requests are welcome on GitHub at https://github.com/haw-itn/bitcoin2graphdb.
@@ -21,14 +21,14 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_runtime_dependency "openassets-ruby", ">= 0.6.5"
23
23
  spec.add_runtime_dependency "daemon-spawn"
24
- spec.add_runtime_dependency "neo4j", "~>7.1.0"
24
+ spec.add_runtime_dependency "neo4j", "~>9.4.0"
25
+ spec.add_runtime_dependency "neo4j-rake_tasks"
25
26
  spec.add_runtime_dependency "activesupport", ">= 4.0.2"
26
27
  spec.add_runtime_dependency "thor"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.10"
29
30
  spec.add_development_dependency "rake", "~> 10.0"
30
31
  spec.add_development_dependency "rspec"
31
- spec.add_development_dependency "database_cleaner"
32
32
  spec.add_development_dependency "octorelease"
33
33
 
34
34
  end
@@ -0,0 +1,9 @@
1
+ class ForceCreateGraphdbModelActiveNodeBaseUuidConstraint < Neo4j::Migrations::Base
2
+ def up
3
+ add_constraint :"Graphdb::Model::ActiveNodeBase", :uuid, force: true
4
+ end
5
+
6
+ def down
7
+ drop_constraint :"Graphdb::Model::ActiveNodeBase", :uuid
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class ForceCreateGraphdbModelAddressAddressIndex < Neo4j::Migrations::Base
2
+ def up
3
+ add_index :"Graphdb::Model::Address", :address, force: true
4
+ end
5
+
6
+ def down
7
+ drop_index :"Graphdb::Model::Address", :address
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class ForceCreateGraphdbModelBlockBlockHashIndex < Neo4j::Migrations::Base
2
+ def up
3
+ add_index :"Graphdb::Model::Block", :block_hash, force: true
4
+ end
5
+
6
+ def down
7
+ drop_index :"Graphdb::Model::Block", :block_hash
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class ForceCreateGraphdbModelAssetIdAssetIdIndex < Neo4j::Migrations::Base
2
+ def up
3
+ add_index :"Graphdb::Model::AssetId", :asset_id, force: true
4
+ end
5
+
6
+ def down
7
+ drop_index :"Graphdb::Model::AssetId", :asset_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class ForceCreateGraphdbModelTransactionTxidIndex < Neo4j::Migrations::Base
2
+ def up
3
+ add_index :"Graphdb::Model::Transaction", :txid, force: true
4
+ end
5
+
6
+ def down
7
+ drop_index :"Graphdb::Model::Transaction", :txid
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of ActiveNode to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.yml definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using neo4j:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ---
14
+ :constraints:
15
+ - CONSTRAINT ON ( `graphdb::model::activenodebase`:`Graphdb::Model::ActiveNodeBase`
16
+ ) ASSERT `graphdb::model::activenodebase`.uuid IS UNIQUE
17
+ - CONSTRAINT ON ( `neo4j::migrations::schemamigration`:`Neo4j::Migrations::SchemaMigration`
18
+ ) ASSERT `neo4j::migrations::schemamigration`.migration_id IS UNIQUE
19
+ :indexes:
20
+ - INDEX ON :Graphdb::Model::Address(address)
21
+ - INDEX ON :Graphdb::Model::AssetId(asset_id)
22
+ - INDEX ON :Graphdb::Model::Block(block_hash)
23
+ - INDEX ON :Graphdb::Model::Transaction(txid)
24
+ :versions:
25
+ - '20190306081251'
26
+ - '20190306081322'
27
+ - '20190306081338'
28
+ - '20190306081351'
29
+ - '20190306081404'
data/lib/base.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'active_support/all'
2
2
  require 'bitcoin2graphdb'
3
- require 'graphdb'
3
+ require 'graphdb'
4
+ require 'neo4j/core/cypher_session/adaptors/http'
@@ -11,7 +11,8 @@ module Bitcoin2Graphdb
11
11
  end
12
12
  neo4j_config = {basic_auth: config[:neo4j][:basic_auth], initialize: neo4j_timeout_ops(config)}
13
13
  Bitcoin2Graphdb::Bitcoin.provider = Bitcoin2Graphdb::Bitcoin::BlockchainProvider.new(config[:bitcoin])
14
- Neo4j::Session.open(:server_db, config[:neo4j][:server], neo4j_config)
14
+ neo4j_adaptor = Neo4j::Core::CypherSession::Adaptors::HTTP.new(config[:neo4j][:server], neo4j_config)
15
+ Neo4j::ActiveBase.on_establish_session { Neo4j::Core::CypherSession.new(neo4j_adaptor) }
15
16
  @sleep_interval = config[:bitcoin][:sleep_interval].nil? ? 600 : config[:bitcoin][:sleep_interval].to_i
16
17
 
17
18
  Graphdb::Model.constants.each {|const_name| Graphdb::Model.const_get(const_name)}
@@ -25,7 +26,7 @@ module Bitcoin2Graphdb
25
26
 
26
27
  def run_with_height(block_height)
27
28
  puts "start migration for block height = #{block_height}. #{Time.now}"
28
- Neo4j::Transaction.run do |tx|
29
+ Neo4j::ActiveBase.run_transaction do |tx|
29
30
  begin
30
31
  Graphdb::Model::Block.create_from_block_height(block_height)
31
32
  @block_height = block_height
@@ -43,7 +44,7 @@ module Bitcoin2Graphdb
43
44
  end
44
45
 
45
46
  def repair_assign_txs(block_height)
46
- Neo4j::Transaction.run do |tx|
47
+ Neo4j::ActiveBase.run_transaction do |tx|
47
48
  begin
48
49
  block = Graphdb::Model::Block.with_height(block_height).first
49
50
  if block
@@ -66,7 +67,7 @@ module Bitcoin2Graphdb
66
67
  end
67
68
 
68
69
  def remove_block(block_height)
69
- Neo4j::Transaction.run do |tx|
70
+ Neo4j::ActiveBase.run_transaction do |tx|
70
71
  begin
71
72
  block = Graphdb::Model::Block.with_height(block_height).first
72
73
  if block.nil?
@@ -83,7 +84,7 @@ module Bitcoin2Graphdb
83
84
  end
84
85
 
85
86
  def import_tx(txid)
86
- Neo4j::Transaction.run do |tx|
87
+ Neo4j::ActiveBase.run_transaction do |tx|
87
88
  begin
88
89
  tx = Graphdb::Model::Transaction.with_txid(txid).first
89
90
  if tx.nil?
@@ -100,7 +101,7 @@ module Bitcoin2Graphdb
100
101
  end
101
102
 
102
103
  def remove_tx(txid)
103
- Neo4j::Transaction.run do |tx|
104
+ Neo4j::ActiveBase.run_transaction do |tx|
104
105
  begin
105
106
  tx = Graphdb::Model::Transaction.with_txid(txid).first
106
107
  if tx.nil?
@@ -1,3 +1,3 @@
1
1
  module Bitcoin2Graphdb
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module Graphdb
2
2
  module Model
3
3
  class Address < ActiveNodeBase
4
- property :address, index: :exact
4
+ property :address
5
5
 
6
6
  has_many :in, :outputs, origin: :addresses, model_class: 'Graphdb::Model::TxOut'
7
7
 
@@ -2,7 +2,7 @@ module Graphdb
2
2
  module Model
3
3
  class Block < ActiveNodeBase
4
4
 
5
- property :block_hash, index: :exact
5
+ property :block_hash
6
6
  property :size, type: Integer
7
7
  property :height, type: Integer
8
8
  property :version
@@ -2,7 +2,7 @@ module Graphdb
2
2
  module Model
3
3
 
4
4
  class AssetId < ActiveNodeBase
5
- property :asset_id, index: :exact
5
+ property :asset_id
6
6
 
7
7
  has_many :in, :outputs, origin: :asset_id, model_class: 'Graphdb::Model::TxOut'
8
8
 
@@ -3,7 +3,7 @@ module Graphdb
3
3
  class Transaction < ActiveNodeBase
4
4
 
5
5
  property :hex
6
- property :txid, index: :exact
6
+ property :txid
7
7
  property :version, type: Integer
8
8
  property :lock_time
9
9
  property :block_hash
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.9
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-06 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openassets-ruby
@@ -44,14 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 7.1.0
47
+ version: 9.4.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: 7.1.0
54
+ version: 9.4.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: neo4j-rake_tasks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: activesupport
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +136,6 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: database_cleaner
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: octorelease
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +171,12 @@ files:
171
171
  - bin/console
172
172
  - bin/setup
173
173
  - bitcoin2graphdb.gemspec
174
+ - db/neo4j/migrate/20190306081251_force_create_graphdb_model_active_node_base_uuid_constraint.rb
175
+ - db/neo4j/migrate/20190306081322_force_create_graphdb_model_address_address_index.rb
176
+ - db/neo4j/migrate/20190306081338_force_create_graphdb_model_block_block_hash_index.rb
177
+ - db/neo4j/migrate/20190306081351_force_create_graphdb_model_asset_id_asset_id_index.rb
178
+ - db/neo4j/migrate/20190306081404_force_create_graphdb_model_transaction_txid_index.rb
179
+ - db/neo4j/schema.yml
174
180
  - exe/bitcoin2graphdb
175
181
  - lib/base.rb
176
182
  - lib/bitcoin2graphdb.rb
@@ -215,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
221
  version: '0'
216
222
  requirements: []
217
223
  rubyforge_project:
218
- rubygems_version: 2.6.13
224
+ rubygems_version: 2.7.9
219
225
  signing_key:
220
226
  specification_version: 4
221
227
  summary: A tool for import Bitcoin blockchain data into neo4j database.