istox 0.1.43.7 → 0.1.43.8

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
  SHA256:
3
- metadata.gz: 7714a5d3bc4fdca3f2127988029cf9433e74e2cdb72c69603a0e9e98f61da712
4
- data.tar.gz: 3862b77faeb51a1a2b565ec2d7bb8daea6833c18ae0bed91df1e9b2b0af02a95
3
+ metadata.gz: 2b6adf4f4cd81ea05078209085ff282a104ca256a195c7d62edf4b93426e2206
4
+ data.tar.gz: a6a61794794811c14fcdb7e83d3a9d8bbf9c59d3d1b5ee9537a71d07e57b89b1
5
5
  SHA512:
6
- metadata.gz: 64f3cc5b014f6689b7440796ec828136c93e319596d0d47a273aa227ab964d327a95de8ba953f6ca83cd0d6f5f73ec1702225676aefa3428917a1aca91afa5bb
7
- data.tar.gz: b924e4cd0728b6ce65c1aa7a234a77c06ce8542386c91157b6934794109684cde458688d657c2ffd3c2eb6f2c5784db0d9f52965753bfaf5d359361854be8f58
6
+ metadata.gz: 8bf29b2086bde99c0cac28eca61e86d224852a574814188a673a83a2d99b5389abd54489996ad3bf479f7dbbc018f3b339c8f17047c0bf1b5157143918685a65
7
+ data.tar.gz: c67f7c9831036e0ed7546f283655d7c7416e8f3a096425c86cb70a44bd72d0788969f836071cb606d681360fdc01e741cdbfe32b02dd71e4db35736bd6f33f60
@@ -19,9 +19,7 @@ module Istox
19
19
  require "istox/helpers/blockchain_receipt_service"
20
20
  require "istox/models/blockchain_receipt"
21
21
  require "istox/models/concerns/blockchain_receipt_query"
22
- require "istox/models/lock"
23
22
  require "istox/consumers/blockchain_status_handler"
24
23
  require "istox/consumers/blockchain_hash_handler"
25
24
  require "istox/migrations/create_blockchain_receipts"
26
- require "istox/migrations/create_locks"
27
25
  end
@@ -2,18 +2,14 @@ module Istox
2
2
  class BlockchainHashHandler
3
3
  class << self
4
4
  def hash_generated(data)
5
- puts "Locking #{data.uuid}"
6
- ::Istox::Lock.acquire(data.uuid) do
7
- receipt = ::Istox::BlockchainReceipt.where(txid: data.uuid, txhash: nil).first
5
+ receipt = ::Istox::BlockchainReceipt.where(txid: data.uuid, txhash: nil).first
8
6
 
9
- if receipt.nil?
10
- puts 'Transaction not found, skipping...'
11
- return
12
- end
13
-
14
- receipt.update!(txhash: data.txnHash)
7
+ if receipt.nil?
8
+ puts 'Transaction not found, skipping...'
9
+ return
15
10
  end
16
- puts "Releasing lock for #{data.uuid}"
11
+
12
+ receipt.update!(txhash: data.txnHash)
17
13
  end
18
14
 
19
15
  end
@@ -18,6 +18,7 @@ module Istox
18
18
  t.datetime :deleted_at, index: true
19
19
  t.timestamps
20
20
  t.string :sid
21
+ t.integer :lock_version
21
22
  end
22
23
  end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = "0.1.43.7"
2
+ VERSION = "0.1.43.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.43.7
4
+ version: 0.1.43.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
@@ -234,10 +234,8 @@ files:
234
234
  - lib/istox/helpers/publisher.rb
235
235
  - lib/istox/interfaces/chainhub/transaction.rb
236
236
  - lib/istox/migrations/create_blockchain_receipts.rb
237
- - lib/istox/migrations/create_locks.rb
238
237
  - lib/istox/models/blockchain_receipt.rb
239
238
  - lib/istox/models/concerns/blockchain_receipt_query.rb
240
- - lib/istox/models/lock.rb
241
239
  - lib/istox/version.rb
242
240
  homepage: http://www.abc.com
243
241
  licenses: []
@@ -1,18 +0,0 @@
1
- module Istox
2
- class CreateLocks < ActiveRecord::Migration[5.0]
3
-
4
- def self.up
5
- create_table :locks do |t|
6
- t.string :name, :limit => 40
7
- t.timestamps
8
- end
9
- add_index :locks, :name, :unique => true
10
- end
11
-
12
- def self.down
13
- remove_index :locks, :column => :name
14
- drop_table :locks
15
- end
16
-
17
- end
18
- end
@@ -1,51 +0,0 @@
1
- module Istox
2
- class Lock < ActiveRecord::Base
3
-
4
- def self.acquire(name)
5
- already_acquired = definitely_acquired?(name)
6
-
7
- if already_acquired
8
- yield
9
- else
10
- begin
11
- create(:name => name) unless find_by_name(name)
12
- rescue ActiveRecord::StatementInvalid
13
- # concurrent create is okay
14
- end
15
-
16
- begin
17
- result = nil
18
-
19
- transaction do
20
- find_by_name(name, :lock => true) # this is the call that will block
21
- acquired_lock(name)
22
- result = yield
23
- end
24
-
25
- result
26
- ensure
27
- maybe_released_lock(name)
28
- end
29
- end
30
- end
31
-
32
- # if true, the lock is acquired
33
- # if false, the lock might still be acquired, because we were in another db transaction
34
- def self.definitely_acquired?(name)
35
- !!Thread.current[:definitely_acquired_locks] and Thread.current[:definitely_acquired_locks].has_key?(name)
36
- end
37
-
38
- def self.acquired_lock(name)
39
- Thread.current[:definitely_acquired_locks] ||= {}
40
- Thread.current[:definitely_acquired_locks][name] = true
41
- end
42
-
43
- def self.maybe_released_lock(name)
44
- Thread.current[:definitely_acquired_locks] ||= {}
45
- Thread.current[:definitely_acquired_locks].delete(name)
46
- end
47
-
48
- private_class_method :acquired_lock, :maybe_released_lock
49
-
50
- end
51
- end