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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0eba92193195b2b9dfd0bb6350981968a9c5fe83
4
- data.tar.gz: df8502f4946b7c5fa770c6587a91d07d8f734449
3
+ metadata.gz: 702d79fd9fb47f7ffd16523a876f9d84462cebe9
4
+ data.tar.gz: c37d187e40612777ee4078aa4065619a58dc7a4a
5
5
  SHA512:
6
- metadata.gz: db72d2baeccb6b886766d492849d3e525a8a0de2424f81429c51e8a981fff841ba79dfda75e73aaad22dd2d565034350fc98357915d186280ae62316266287a9
7
- data.tar.gz: 52a0b36366d4294c9016fc2c35a2716eb3d8dcb1f9bcf85587a44b6a742f9ddbc3e3f9a26501fe826460abfe021f46a54e41e8155ef8b7ada3639966f46ded01
6
+ metadata.gz: 5e77036ba699a9147125077510d060c68b0bb33425e4998a7355e7dff81466e5ebda63e1ad08402eab4baf708d2f9d4f127344746ea9454ab7729545bc7268a8
7
+ data.tar.gz: 168b34282906e0fcc83bce76208f6640a33b34a0c6138f75d8f69614d6bbc82f417ff15ab769774ec3349136cc90095ebfff25eab7edf91028e1e2d4100e9f5f
@@ -5,4 +5,5 @@ require 'bitcoin2graphdb/version'
5
5
  module Bitcoin2Graphdb
6
6
  autoload :Bitcoin, 'bitcoin2graphdb/bitcoin'
7
7
  autoload :Migration, 'bitcoin2graphdb/migration'
8
+ autoload :Error, 'bitcoin2graphdb/error'
8
9
  end
@@ -0,0 +1,4 @@
1
+ module Bitcoin2Graphdb
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Bitcoin2Graphdb
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -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.8
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-09-13 00:00:00.000000000 Z
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