bitcoin2graphdb 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bitcoin2graphdb.rb +1 -0
- data/lib/bitcoin2graphdb/error.rb +4 -0
- data/lib/bitcoin2graphdb/migration.rb +1 -1
- data/lib/bitcoin2graphdb/version.rb +1 -1
- data/lib/graphdb/model/block.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 702d79fd9fb47f7ffd16523a876f9d84462cebe9
|
4
|
+
data.tar.gz: c37d187e40612777ee4078aa4065619a58dc7a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e77036ba699a9147125077510d060c68b0bb33425e4998a7355e7dff81466e5ebda63e1ad08402eab4baf708d2f9d4f127344746ea9454ab7729545bc7268a8
|
7
|
+
data.tar.gz: 168b34282906e0fcc83bce76208f6640a33b34a0c6138f75d8f69614d6bbc82f417ff15ab769774ec3349136cc90095ebfff25eab7edf91028e1e2d4100e9f5f
|
data/lib/bitcoin2graphdb.rb
CHANGED
@@ -29,7 +29,7 @@ module Bitcoin2Graphdb
|
|
29
29
|
begin
|
30
30
|
Graphdb::Model::Block.create_from_block_height(block_height)
|
31
31
|
@block_height = block_height
|
32
|
-
rescue OpenAssets::Provider::ApiError => e
|
32
|
+
rescue OpenAssets::Provider::ApiError, Bitcoin2Graphdb::Error => e
|
33
33
|
if e.message == '{"code"=>-8, "message"=>"Block height out of range"}'
|
34
34
|
puts "Block height out of range. sleep #{@sleep_interval} seconds."
|
35
35
|
sleep @sleep_interval
|
data/lib/graphdb/model/block.rb
CHANGED
@@ -49,6 +49,12 @@ module Graphdb
|
|
49
49
|
block.difficulty = hash['difficulty']
|
50
50
|
block.chain_work = hash['chainwork']
|
51
51
|
block.previous_block_hash = hash['previousblockhash']
|
52
|
+
# check previous block exist?
|
53
|
+
begin
|
54
|
+
Bitcoin2Graphdb::Bitcoin.provider.block(block.previous_block_hash) if block.previous_block_hash # except genesis block
|
55
|
+
rescue OpenAssets::Provider::ApiError
|
56
|
+
raise Bitcoin2Graphdb::Error, 'previous block not found. maybe re-org occured.'
|
57
|
+
end
|
52
58
|
block.next_block_hash = hash['nextblockhash']
|
53
59
|
block.confirmations = hash['confirmations']
|
54
60
|
block.save!
|
@@ -66,6 +72,7 @@ module Graphdb
|
|
66
72
|
end
|
67
73
|
|
68
74
|
private
|
75
|
+
|
69
76
|
def chain_previous_block
|
70
77
|
unless self.previous_block_hash.nil?
|
71
78
|
self.previous_block = Block.with_block_hash(self.previous_block_hash).first
|
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.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openassets-ruby
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/bitcoin2graphdb/bitcoin.rb
|
178
178
|
- lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb
|
179
179
|
- lib/bitcoin2graphdb/cli.rb
|
180
|
+
- lib/bitcoin2graphdb/error.rb
|
180
181
|
- lib/bitcoin2graphdb/migration.rb
|
181
182
|
- lib/bitcoin2graphdb/tasks/migration.rake
|
182
183
|
- lib/bitcoin2graphdb/version.rb
|