Skip to content

Commit

Permalink
Reduce TTL of txns to 2 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
EggPool committed Nov 12, 2019
1 parent 7718efc commit 22ead70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,17 @@ def process_transactions(block):
# Cache for multiple tx from same address
balances = {}

# TODO: remove condition after HF
if block_instance.block_height_new >= 1450000:
oldest_possible_tx = miner_tx.q_block_timestamp - 60 * 60 * 2
else:
# Was 24 h before
oldest_possible_tx = miner_tx.q_block_timestamp - 60 * 60 * 24

for tx_index, transaction in enumerate(block):
if float(transaction[0]) < oldest_possible_tx:
raise ValueError("txid {} from {} is older ({}) than oldest possible date ({})"
.format(transaction[4][:56], transaction[1], transaction[0], oldest_possible_tx))
db_timestamp = '%.2f' % quantize_two(transaction[0])
db_address = str(transaction[1])[:56]
db_recipient = str(transaction[2])[:56]
Expand Down
9 changes: 6 additions & 3 deletions mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# from Cryptodome.PublicKey import RSA
# from Cryptodome.Signature import PKCS1_v1_5

__version__ = "0.0.7a"
__version__ = "0.0.7b"

"""
0.0.5g - Add default param to mergedts for compatibility
Expand All @@ -31,6 +31,7 @@
0.0.6b - Raise freeze tolerance to > 15 minutes old txs.
0.0.6c - Return last exception to client in all cases
0.0.7a - Add support for mandatory message addresses
0.0.7b - Reduce age of valid txns to 2 hours
"""

MEMPOOL = None
Expand All @@ -40,7 +41,9 @@
DEBUG_DO_NOT_SEND_TX = False

# Tx age limit (in seconds) - Default 82800
REFUSE_OLDER_THAN = 82800
# REFUSE_OLDER_THAN = 82800
REFUSE_OLDER_THAN = 60 * 60 * 2 # reduced to 2 hours
# See also SQL_PURGE a few lines down.

# How long for freeze nodes that send late enough tx we already have in ledger
FREEZE_MIN = 5
Expand All @@ -55,7 +58,7 @@
"public_key TEXT, operation TEXT, openfield TEXT, mergedts INTEGER(4) not null default (strftime('%s','now')) )"

# Purge old txs that may be stuck
SQL_PURGE = "DELETE FROM transactions WHERE timestamp <= strftime('%s', 'now', '-1 day')"
SQL_PURGE = "DELETE FROM transactions WHERE timestamp <= strftime('%s', 'now', '-2 hour')"

# Delete all transactions
SQL_CLEAR = "DELETE FROM transactions"
Expand Down

0 comments on commit 22ead70

Please sign in to comment.