Skip to content

Commit

Permalink
Raise mempool freeze tolerance to 15 min instead of 3
Browse files Browse the repository at this point in the history
  • Loading branch information
EggPool committed Jul 28, 2019
1 parent f4047ed commit 0c57b5b
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ config_custom.txt
sequencing_last
# ignore polysign, so devs can have a symlink or local dev version.
polysign
# ignore ledger queries, for the time being.
ledger_queries.py
44 changes: 44 additions & 0 deletions cmd_hn_last_block_ts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
test cmd for the hn_last_block_ts command.
Usage:
python3 cmd_hn_last_block_ts
"""


import connections
import json
import socks
import sys


__version__ = "0.0.1"


ORIGIN_OF_TIME = 1534716000 # Real Origin: August 20
POS_SLOT_TIME_MIN = 3 # Real world setting?
POS_SLOT_TIME_SEC = POS_SLOT_TIME_MIN * 60
MAX_ROUND_SLOTS = 19 # Real world. 19+1 = 20 , 3x20 = 60 (round time)
END_ROUND_SLOTS = 1
# Round time in seconds
ROUND_TIME_SEC = POS_SLOT_TIME_SEC * (MAX_ROUND_SLOTS + END_ROUND_SLOTS)


def hn_last_block_ts():
s = socks.socksocket()
s.settimeout(10)
s.connect(("127.0.0.1", 5658))
# Last param is ip, to get feed of a specific ip, False for all.
connections.send(s, "HN_last_block_ts")
res = connections.receive(s)
return res


if __name__ == "__main__":
res_as_dict = hn_last_block_ts()
print("Answer (<=0 means fail):")
print(json.dumps(res_as_dict, indent=2))
46 changes: 46 additions & 0 deletions cmd_hn_reg_round.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
cmd for the hn_reg_round command.
Usage:
python3 cmd_hn_reg_round.py round
"""


import connections
import json
import socks
import sys


__version__ = "0.0.1"


ORIGIN_OF_TIME = 1534716000 # Real Origin: August 20
POS_SLOT_TIME_MIN = 3 # Real world setting?
POS_SLOT_TIME_SEC = POS_SLOT_TIME_MIN * 60
MAX_ROUND_SLOTS = 19 # Real world. 19+1 = 20 , 3x20 = 60 (round time)
END_ROUND_SLOTS = 1
# Round time in seconds
ROUND_TIME_SEC = POS_SLOT_TIME_SEC * (MAX_ROUND_SLOTS + END_ROUND_SLOTS)


def hn_reg_round(round: int, pow_height: int=0):
s = socks.socksocket()
s.settimeout(10)
s.connect(("127.0.0.1", 5658))
timestamp = ORIGIN_OF_TIME + round * ROUND_TIME_SEC
# Last param is ip, to get feed of a specific ip, False for all.
connections.send(s, "HN_reg_round {} {} {} False".format(round, timestamp, pow_height))
res = connections.receive(s)
return res


if __name__ == "__main__":
_, round_string = sys.argv
res_as_dict = hn_reg_round(int(round_string))
print("Answer (<=0 means fail):")
print(json.dumps(res_as_dict, indent=2))
7 changes: 4 additions & 3 deletions mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from quantizer import *
from polysign.signerfactory import SignerFactory

__version__ = "0.0.6"
__version__ = "0.0.6b"

"""
0.0.5g - Add default param to mergedts for compatibility
0.0.5f - Using polysign
0.0.5e - add mergedts timestamp to tx for better handling of late txs
quicker unfreeze
less strict freezing
0.0.6b - Raise freeze tolerance to > 15 minutes old txs.
"""

MEMPOOL = None
Expand Down Expand Up @@ -569,8 +570,8 @@ def merge(self, data, peer_ip, c, size_bypass=False, wait=False, revert=False):
mempool_result.append("That transaction is already in our ledger")
# Can be a syncing node. Do not request mempool from this peer until FREEZE_MIN min
# ledger_in is the ts of the tx in ledger. if it's recent, maybe the peer is just one block late.
# give him 3 minute margin.
if (peer_ip != '127.0.0.1') and (ledger_in < time_now - 60 * 3):
# give him 15 minute margin.
if (peer_ip != '127.0.0.1') and (ledger_in < time_now - 60 * 15):
with self.peers_lock:
self.peers_sent[peer_ip] = time.time() + FREEZE_MIN * 60
self.app_log.warning("Freezing mempool from {} for {} min.".format(peer_ip, FREEZE_MIN))
Expand Down

0 comments on commit 0c57b5b

Please sign in to comment.