txcatcher 0.1.97 → 0.1.98

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: f29dc9fd87fb3bbe08472158795885dfd87077f062ed4d9864c19d34b06b3707
4
- data.tar.gz: bf39521a2f5fb5717f6ecdf39fb032b5240de2f3536350c4fbbba360c65b1aac
3
+ metadata.gz: 639a96cc41fac3d3fafdff646c0dbe789cde842cdc1997bfc4f49f9972e630e1
4
+ data.tar.gz: 30131171ad4e00a398aa5870329f385023fa7e4f745fd9d228148ed1eb9bb5c3
5
5
  SHA512:
6
- metadata.gz: ee2b7e2ef677b9b9bf4d48a69942f5a4bf98fd9dc699f3f2ae308b47cc3e37e7274e1e8a6788bb1ea120e92c4d787597c790513e6d0c27cfdcdb482ac610f064
7
- data.tar.gz: 973b747061bd98656e795c039af4e38a519c8459bfb24f90442db82252efe4daf700f8cba7c8a6c866b6b4624c4261de360b6ac774516a50e94566492a150938
6
+ metadata.gz: 5c834551b17c5d4b28d48b76d75643b538897de6f3eced17d959eb1f3dbc8cf2c3da94fca920117cbd1c7e7e06b147d174c5f798777365b26b80bcb97f9a358d
7
+ data.tar.gz: f789fc242df54ad185e5b59f0f31e1ea26bcd45a674e3d91a43d73fe0b83cab89f5b56a469ec5090d8f8e4cdc66dbf83047558196cf7be840ac18d3921e90b7d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.97
1
+ 0.1.98
@@ -44,7 +44,7 @@ module TxCatcher
44
44
 
45
45
  # Queries rpc node to check whether the transaction has been included in any of the blocks,
46
46
  # but only if current block_height is nil.
47
- def update_block_height!(limit=100)
47
+ def update_block_height!(limit=100,dry_run=false)
48
48
 
49
49
  # This calculates the approximate number of blocks to check.
50
50
  # So, for example, if transaction is less than 10 minutes old,
@@ -65,7 +65,7 @@ module TxCatcher
65
65
  LOGGER.report "--- checking block #{TxCatcher.current_block_height - i} for tx #{self.txid}"
66
66
  if block["tx"] && block["tx"].include?(self.txid)
67
67
  LOGGER.report "tx #{self.txid} block height updated to #{block["height"]}"
68
- self.update(block_height: block["height"])
68
+ self.update(block_height: block["height"]) if !dry_run
69
69
  return block["height"].to_i
70
70
  end
71
71
  end
@@ -66,18 +66,26 @@ module TxCatcher
66
66
  model = Address.where(address: addr).eager(deposits: :transactions).first
67
67
  return [200, {}, "{}"] unless model
68
68
 
69
+ txs_to_update = []
69
70
  transactions = model.deposits.map { |d| d.transaction }
70
71
  utxos = transactions.map do |t|
71
72
  outs = t.tx_hash["vout"].select { |out| out["scriptPubKey"]["addresses"] == [addr] }
73
+ txs_to_update << t if outs.length > 0
72
74
  outs.map! do |out|
73
- t.update(protected: true) unless t.protected
74
- t.update_block_height!
75
75
  out["confirmations"] = t.confirmations || 0
76
76
  out["txid"] = t.txid
77
77
  out
78
78
  end
79
79
  outs
80
80
  end.flatten
81
+
82
+ # Update all txs after we map them. We don't use regular Transaction#update
83
+ # in the #map loop above, because this will quickly get out of hand and result
84
+ # in a gateway timeout, if there are a lot of transactions to be updated. Instead,
85
+ # we collect all txs in an array and then update them in bulk here.
86
+ txs_to_update.map! { |t| [t.id, true, t.update_block_height!] }
87
+ TxCatcher.db_connection[:transactions].import([:id, :protected, :bock_height], txs_to_update)
88
+
81
89
  [200, {}, utxos.to_json]
82
90
  end
83
91
 
data/txcatcher.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: txcatcher 0.1.97 ruby lib
5
+ # stub: txcatcher 0.1.98 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "txcatcher"
9
- s.version = "0.1.97"
8
+ s.name = "txcatcher".freeze
9
+ s.version = "0.1.98"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Roman Snitko".freeze]
14
- s.date = "2018-03-09"
14
+ s.date = "2018-09-28"
15
15
  s.description = "Ccurrently, the only job of this gem is to collect all new Bitcoin/Litecoin transactions, store them in a DB, index addresses.".freeze
16
16
  s.email = "roman.snitko@gmail.com".freeze
17
17
  s.executables = ["txcatcher".freeze, "txcatcher-monitor".freeze]
@@ -64,7 +64,7 @@ Gem::Specification.new do |s|
64
64
  ]
65
65
  s.homepage = "http://github.com/snitko/txcatcher".freeze
66
66
  s.licenses = ["MIT".freeze]
67
- s.rubygems_version = "2.6.11".freeze
67
+ s.rubygems_version = "2.7.7".freeze
68
68
  s.summary = "An lightweight version of Bitpay's Insight, allows to check Bitcoin/Litecoin addresses".freeze
69
69
 
70
70
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txcatcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.97
4
+ version: 0.1.98
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-28 00:00:00.000000000 Z
11
+ date: 2018-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: goliath
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  requirements: []
210
210
  rubyforge_project:
211
- rubygems_version: 2.7.6
211
+ rubygems_version: 2.7.7
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: An lightweight version of Bitpay's Insight, allows to check Bitcoin/Litecoin