bitcoin2graphdb 0.1.6 → 0.1.7
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75f690fbe30d0ad157becf1dd15cc8a4b16e906e
|
4
|
+
data.tar.gz: b1bc20f6a77c16e6639bbb888af0ddb1a307cc8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca6097456ea0180ff55cc0f7519c0ef25ba99671b3ec54ebf924c43bda44e09fc7dc896677070d11143061eeb5551469a145b6c1be55783e677b82914c72c526
|
7
|
+
data.tar.gz: ed380cd3af6f18a5315017802cad28274a147bb8f59f1743869222d3321f8e33eedc0b9d01a234a7cf39b3fa7ab9e946a66ae7b4635f03c03dc28dcecbdb4dde
|
data/Rakefile
CHANGED
@@ -12,39 +12,34 @@ namespace :b2g do
|
|
12
12
|
desc 'Import specified block to neo4j database.'
|
13
13
|
task :import_block, [:block_height,:config_path] do |task, args|
|
14
14
|
puts "import #{args.block_height} block."
|
15
|
-
|
15
|
+
get_migration(args.config_path).run_with_height(args.block_height.to_i)
|
16
16
|
end
|
17
17
|
|
18
18
|
desc 'Remove specified block from neo4j database.'
|
19
19
|
task :remove_block, [:block_height,:config_path] do |task, args|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
20
|
+
puts "remove #{args.block_height} block."
|
21
|
+
get_migration(args.config_path).remove_block(args.block_height.to_i)
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Import specified transaction to neo4j database.'
|
25
|
+
task :import_tx, [:txid,:config_path] do |task, args|
|
26
|
+
get_migration(args.config_path).import_tx(args.txid)
|
28
27
|
end
|
29
28
|
|
30
29
|
desc 'Remove specified transaction from neo4j database.'
|
31
30
|
task :remove_tx, [:txid,:config_path] do |task, args|
|
32
|
-
|
33
|
-
tx = Graphdb::Model::Transaction.with_txid(args.txid).first
|
34
|
-
if tx.nil?
|
35
|
-
puts "txid #{args.txid} does not exist."
|
36
|
-
else
|
37
|
-
tx.destroy
|
38
|
-
puts "tixd #{args.txid} is deleted."
|
39
|
-
end
|
31
|
+
get_migration(args.config_path).remove_tx(args.txid)
|
40
32
|
end
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
desc 'Repair specified transaction.'
|
35
|
+
task :repair_tx, [:txid,:config_path] do |task, args|
|
36
|
+
get_migration(args.config_path).remove_tx(args.txid)
|
37
|
+
get_migration(args.config_path).import_tx(args.txid)
|
45
38
|
end
|
46
39
|
|
47
|
-
|
48
|
-
|
40
|
+
private
|
41
|
+
def get_migration(config_path)
|
42
|
+
config = YAML.load(File.read(config_path)).deep_symbolize_keys[:bitcoin2graphdb]
|
43
|
+
Bitcoin2Graphdb::Migration.new(config)
|
49
44
|
end
|
50
45
|
end
|
@@ -36,6 +36,57 @@ module Bitcoin2Graphdb
|
|
36
36
|
puts "end migration for block height #{block_height}. #{Time.now}"
|
37
37
|
end
|
38
38
|
|
39
|
+
def remove_block(block_height)
|
40
|
+
Neo4j::Transaction.run do |tx|
|
41
|
+
begin
|
42
|
+
block = Graphdb::Model::Block.with_height(block_height).first
|
43
|
+
if block.nil?
|
44
|
+
puts "block height #{block_height} does not exist."
|
45
|
+
else
|
46
|
+
block.destroy
|
47
|
+
puts "block height #{block_height} is deleted."
|
48
|
+
end
|
49
|
+
rescue => e
|
50
|
+
puts e.message
|
51
|
+
tx.failure
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def import_tx(txid)
|
57
|
+
Neo4j::Transaction.run do |tx|
|
58
|
+
begin
|
59
|
+
tx = Graphdb::Model::Transaction.with_txid(txid).first
|
60
|
+
if tx.nil?
|
61
|
+
Graphdb::Model::Transaction.create_from_txid(txid)
|
62
|
+
puts "import #{txid} tx."
|
63
|
+
else
|
64
|
+
puts "txid #{txid} is already exist."
|
65
|
+
end
|
66
|
+
rescue => e
|
67
|
+
puts e.message
|
68
|
+
tx.failure
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def remove_tx(txid)
|
74
|
+
Neo4j::Transaction.run do |tx|
|
75
|
+
begin
|
76
|
+
tx = Graphdb::Model::Transaction.with_txid(txid).first
|
77
|
+
if tx.nil?
|
78
|
+
puts "txid #{txid} does not exist."
|
79
|
+
else
|
80
|
+
tx.destroy
|
81
|
+
puts "tixd #{txid} is deleted."
|
82
|
+
end
|
83
|
+
rescue => e
|
84
|
+
puts e.message
|
85
|
+
tx.failure
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
39
90
|
private
|
40
91
|
def current_block_height
|
41
92
|
return @block_height if @block_height
|
@@ -3,6 +3,7 @@ module Graphdb
|
|
3
3
|
|
4
4
|
class AssetId < ActiveNodeBase
|
5
5
|
property :asset_id, index: :exact, constraint: :unique
|
6
|
+
has_many :in, :outputs, origin: :asset_id, model_class: TxOut
|
6
7
|
|
7
8
|
validates :asset_id, :presence => true
|
8
9
|
|
@@ -17,6 +18,12 @@ module Graphdb
|
|
17
18
|
end
|
18
19
|
a
|
19
20
|
end
|
21
|
+
|
22
|
+
# Get issuance transactions
|
23
|
+
def issuance_txs
|
24
|
+
outputs.select{|o|o.oa_output_type == 'issuance'}.map{|o|o.transaction}.sort{|a,b| b.block_time <=> a.block_time}
|
25
|
+
end
|
26
|
+
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
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.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openassets-ruby
|