txcatcher 0.1.74 → 0.1.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/txcatcher +10 -5
- data/lib/txcatcher/cleaner.rb +27 -23
- data/txcatcher.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b7dc3ae4c6fd912e914dd8f96cfd7dee17070d6
|
|
4
|
+
data.tar.gz: 698dfaee6449d7d24a19f72ce59de0fb472f8a27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0e8283e22af52664c2a6b9ae46f77f4447d6cd2a322dc54fe28a2cb9f542419381270b8dc6c7f239abbde81dd5e6d1de6ee683df6d7a4214c9d3043c41f8373
|
|
7
|
+
data.tar.gz: 20029f87d61dab8a0443441986606f624483216ce03624158685d1226c6e7bcd56433a76abf4c71d5b9967b07909d744c3944cf5bf6bf638e04e13877ba36921
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.75
|
data/bin/txcatcher
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
data/lib/txcatcher/cleaner.rb
CHANGED
|
@@ -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
|
-
|
|
19
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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-
|
|
11
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: goliath
|