txcatcher 0.1.74 → 0.1.75

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: 92936b57477c0542131d557f44821198ccf5c457
4
- data.tar.gz: 4386bca28f25372e778571847f0fb01e37f5bea0
3
+ metadata.gz: 9b7dc3ae4c6fd912e914dd8f96cfd7dee17070d6
4
+ data.tar.gz: 698dfaee6449d7d24a19f72ce59de0fb472f8a27
5
5
  SHA512:
6
- metadata.gz: 1ead00c396df098d2d36adda908fd3b65726362a02f0a1ec626359e63e5759fb704bed8fc35716a5b2ef489de6388edb48a809b267bea8c986cecd98915ec8a7
7
- data.tar.gz: 64c0a5ee8ad9a0b2fe75d830b796b75eef9c59273edf7238b2d2cbda5e429c7a75c2905f110800fba20411ea41701cecd3dfc2cf83215671f0170d77b5e9db35
6
+ metadata.gz: a0e8283e22af52664c2a6b9ae46f77f4447d6cd2a322dc54fe28a2cb9f542419381270b8dc6c7f239abbde81dd5e6d1de6ee683df6d7a4214c9d3043c41f8373
7
+ data.tar.gz: 20029f87d61dab8a0443441986606f624483216ce03624158685d1226c6e7bcd56433a76abf4c71d5b9967b07909d744c3944cf5bf6bf638e04e13877ba36921
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.74
1
+ 0.1.75
data/bin/txcatcher CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'goliath'
3
+ clean = ARGV.include?("--clean")
4
+ require 'goliath' unless clean
4
5
  require_relative '../lib/txcatcher'
5
- require_relative '../lib/txcatcher/server'
6
- require 'ffi-rzmq'
7
6
 
8
- TxCatcher::Catcher.new(name: TxCatcher::Config.zeromq)
9
- TxCatcher::Cleaner.start
7
+ if clean
8
+ TxCatcher::Cleaner.start(run_once: true)
9
+ else
10
+ require_relative '../lib/txcatcher/server'
11
+ require 'ffi-rzmq'
12
+ TxCatcher::Catcher.new(name: TxCatcher::Config.zeromq)
13
+ TxCatcher::Cleaner.start_in_thread
14
+ end
@@ -12,32 +12,36 @@ module TxCatcher
12
12
  end
13
13
 
14
14
  def start(run_once: false)
15
+ loop do
16
+ @@cleaning_counter = { transactions: 0, deposits: 0, addresses: 0 }
17
+ db_tx_count = if Config.protected_transactions
18
+ TxCatcher::Transaction.where(Sequel.~(protected: true)).count
19
+ else
20
+ TxCatcher::Transaction.count
21
+ end
22
+ $stdout.print "Cleaning transactions in DB..."
23
+ $stdout.print "#{db_tx_count} now, needs to be below #{Config.max_db_transactions_stored}\n"
24
+ if db_tx_count > Config.max_db_transactions_stored
25
+ number_to_delete = (db_tx_count - Config.max_db_transactions_stored) + (Config.max_db_transactions_stored*0.1).round
26
+ clean_transactions(number_to_delete)
27
+ $stdout.puts "DB cleaned: #{@@cleaning_counter.to_s}"
28
+ else
29
+ $stdout.puts "Nothing to be cleaned from DB, size is below threshold."
30
+ end
31
+ if @stop || run_once
32
+ @@stopped = true
33
+ break
34
+ end
35
+ sleep Config.db_clean_period_seconds
36
+ end
37
+ end
38
+
39
+ def start_in_thread(run_once: false)
15
40
  @@stopped = false
16
41
  @@stop = false
17
42
  Thread.new do
18
- loop do
19
- @@cleaning_counter = { transactions: 0, deposits: 0, addresses: 0 }
20
- db_tx_count = if Config.protected_transactions
21
- TxCatcher::Transaction.where(Sequel.~(protected: true)).count
22
- else
23
- TxCatcher::Transaction.count
24
- end
25
- $stdout.print "Cleaning transactions in DB..."
26
- $stdout.print "#{db_tx_count} now, needs to be below #{Config.max_db_transactions_stored}\n"
27
- if db_tx_count > Config.max_db_transactions_stored
28
- number_to_delete = (db_tx_count - Config.max_db_transactions_stored) + (Config.max_db_transactions_stored*0.1).round
29
- clean_transactions(number_to_delete)
30
- $stdout.puts "DB cleaned: #{@@cleaning_counter.to_s}"
31
- else
32
- $stdout.puts "Nothing to be cleaned from DB, size is below threshold."
33
- end
34
- if @stop || run_once
35
- @@stopped = true
36
- break
37
- end
38
- sleep Config.db_clean_period_seconds
39
- end # loop
40
- end # Thread
43
+ start(run_once: run_once)
44
+ end
41
45
  @@stopped
42
46
  end
43
47
 
data/txcatcher.gemspec CHANGED
@@ -2,11 +2,11 @@
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.74 ruby lib
5
+ # stub: txcatcher 0.1.75 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "txcatcher"
9
- s.version = "0.1.74"
9
+ s.version = "0.1.75"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
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.74
4
+ version: 0.1.75
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-02-07 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: goliath