istox 0.1.67 → 0.1.68

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: 521821a9c200ed635e2566632ca07539e3abdd01bec5320fb0b0eb7f4865bce2
4
- data.tar.gz: ea237b283651ef6885b13cae392cbd5fe27ee7e1a8357df73c9aadea06a55a45
3
+ metadata.gz: 45ce1d566ed6248aa5ce93677cc65c10c6daebfd0f4b168514cc38e268d53130
4
+ data.tar.gz: fa148b1ecb82531f8773171436efcf427176b64509b2202cc37201d5e33d158a
5
5
  SHA512:
6
- metadata.gz: d37092798a3a63de395a3a7214acee390a168e4699f824e6a76afb2b81c1a91d2a5131df13b40465f5345881d9c2e5c476f03750fc7fe5e7aed3123f7e2473f1
7
- data.tar.gz: 0266f50e0d96cc0df8a52329b81c701ca9d5ac8bfe13b83c467415029d703b45b3d71fa2c8c7172c5cc6014164f9cff64d26048b7ca965cae52dc66fbb5eaedf
6
+ metadata.gz: 3825904cd3232d5db9e3e9760d0d29016be5381a0e2d3b319646eded1c0cb6f065b97b32c7e126c5fa6de422e7e81a91177eb10993405806c2b549d54a491bf3
7
+ data.tar.gz: 3964cc194458dcbad28f0abea7faeaff7f281e23de55078adb5ba49fe7f996007012245918d18c5398f8f2c962dbd64531df8aa8cf34985dcc27cc7860a642f0
@@ -11,6 +11,8 @@ module Istox
11
11
 
12
12
  # sid cannot be nil
13
13
  update_receipt = ::Istox::BlockchainReceipt.where(txid: data.uuid, txhash: nil).where.not(sid: nil).first
14
+ raise "Unable to find receipt to update" if update_receipt.blank?
15
+
14
16
  update_receipt.update!(txhash: data.txnHash)
15
17
  end
16
18
  end
@@ -1,6 +1,46 @@
1
1
  module Istox
2
2
  class BlockchainStatusHandler
3
3
  class << self
4
+
5
+ def txn_data_confirmed(transactions)
6
+ found_txns = transactions.map do |transaction|
7
+ receipt = ::Istox::BlockchainReceipt.where(txid: transaction.uuid).first
8
+ if !receipt.blank?
9
+ handling_receipt = ::Istox::BlockchainReceipt.where(txhash: transaction.id, txid: transaction.uuid).first
10
+ raise 'Unable to find receipt' if handling_receipt.blank?
11
+ transaction
12
+ else
13
+ puts 'Transaction doesnt belong here, skipping...'
14
+ nil
15
+ end
16
+ end.compact
17
+
18
+ found_txns.each do |transaction|
19
+ receipt = ::Istox::BlockchainReceipt.where(txhash: transaction.id, txid: transaction.uuid).first
20
+
21
+ resource = begin
22
+ class_eval("::#{receipt.resource_name}").find(receipt.resource_id)
23
+ rescue => e
24
+ puts "Class not found, skipping..."
25
+ next
26
+ end
27
+
28
+ receipt_list = get_receipt_list(resource)
29
+
30
+ next if resource_handled?(receipt_list)
31
+
32
+ next if resource.outcome == 'pending'
33
+
34
+ if resource.outcome == 'confirmed'
35
+ resource.handle_confirm(receipt.resource_action)
36
+
37
+ mark_resource_handled(receipt_list)
38
+ publish_to_frontend(resource, true, receipt, receipt.sid, receipt_list)
39
+ end
40
+
41
+ end
42
+ end
43
+
4
44
  def txn_status_changed(transactions, payload_target)
5
45
  # pre check all transaction does exists
6
46
  found_txns = transactions.map do |transaction|
@@ -18,7 +58,7 @@ module Istox
18
58
  found_txns.each do |transaction|
19
59
  receipt = ::Istox::BlockchainReceipt.where(txhash: transaction.id, txid: transaction.uuid).first
20
60
 
21
- next if !(%w[failed confirmed pending].include?(transaction.status))
61
+ next if !(%w[failed pending].include?(transaction.status))
22
62
  receipt.update!(status: transaction.status)
23
63
 
24
64
  resource = begin
@@ -32,16 +72,16 @@ module Istox
32
72
 
33
73
  next if resource_handled?(receipt_list)
34
74
 
35
- if transaction.status == 'confirmed'
36
- next if resource.outcome == 'pending'
75
+ # if transaction.status == 'confirmed'
76
+ # next if resource.outcome == 'pending'
37
77
 
38
- if resource.outcome == 'confirmed'
39
- resource.handle_confirm(receipt.resource_action)
78
+ # if resource.outcome == 'confirmed'
79
+ # resource.handle_confirm(receipt.resource_action)
40
80
 
41
- mark_resource_handled(receipt_list)
42
- publish_to_frontend(resource, true, receipt, receipt.sid, receipt_list)
43
- end
44
- end
81
+ # mark_resource_handled(receipt_list)
82
+ # publish_to_frontend(resource, true, receipt, receipt.sid, receipt_list)
83
+ # end
84
+ # end
45
85
 
46
86
  if transaction.status == 'failed'
47
87
  resource.handle_fail(receipt.resource_action)
@@ -4,8 +4,20 @@ module Istox
4
4
  class LogFormatter
5
5
  def call(severity, time, progname, msg='')
6
6
  return '' if msg.blank?
7
- return "timestamp='#{time}' level=#{severity} progname='#{progname}' #{processed_message(msg)}\n" if progname.present?
8
- "timestamp='#{time}' level=#{severity} #{processed_message(msg)}\n"
7
+
8
+ hash = {
9
+ level: severity,
10
+ message: processed_message(msg)
11
+ }
12
+
13
+ if progname.present?
14
+ hash[:app] = progname
15
+ end
16
+
17
+ return JSON.pretty_generate(hash) + "\n"
18
+
19
+ # return "timestamp='#{time}' level=#{severity} progname='#{progname}' #{processed_message(msg)}\n" if progname.present?
20
+ # "timestamp='#{time}' level=#{severity} #{processed_message(msg)}\n"
9
21
  end
10
22
 
11
23
  private
@@ -13,7 +25,7 @@ module Istox
13
25
  def processed_message(msg)
14
26
  return msg.map { |k, v| "#{k}='#{v.strip}'" }.join(' ') if msg.is_a?(Hash)
15
27
 
16
- "message='#{msg.strip}'"
28
+ msg
17
29
  end
18
30
  end
19
31
  end
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = "0.1.67"
2
+ VERSION = "0.1.68"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.67
4
+ version: 0.1.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-14 00:00:00.000000000 Z
11
+ date: 2019-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  version: '0'
317
317
  requirements: []
318
318
  rubyforge_project:
319
- rubygems_version: 2.7.8
319
+ rubygems_version: 2.7.7
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: istox backend shared gem