Skip to content

Commit

Permalink
fix the backoff time of a slow node concerning block creation
Browse files Browse the repository at this point in the history
Resolves #4
  • Loading branch information
florianmorath committed May 1, 2018
1 parent ae6931a commit df49802
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions piChain/PaxosLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Node(ConnectionManager):
tx_committed (Callable): method given by app service that is called once a transaction has been committed.
rtts (dict): Mapping from peer_node_id to RTT. Used to estimate expected round trip time.
expected_rtt (float): based on this rtt the timeouts are computed.
slow_timeout (float): fix patience of a slow node (u.a.r only set once).
slow_timeout_backoff (float): fix additional timeout backoff of a slow node (u.a.r only set once).
n (int): total numberof nodes.
retry_commit_timeout_queued (bool): is there a timeout in queue that will retry to commit.
"""
Expand Down Expand Up @@ -106,7 +106,7 @@ def __init__(self, node_index, peers_dict):
# timeout/timing variables
self.rtts = {}
self.expected_rtt = 1
self.slow_timeout = None
self.slow_timeout_backoff = None
self.retry_commit_timeout_queued = False

self.n = len(self.peers)
Expand Down Expand Up @@ -615,13 +615,13 @@ def get_patience(self):
patience = (1 + EPSILON) * self.expected_rtt

else:
if self.slow_timeout is None:
patience = random.uniform((2. + EPSILON) * self.expected_rtt,
(2. + EPSILON) * self.expected_rtt +
self.n * self.expected_rtt * 0.5)
self.slow_timeout = patience
else:
patience = self.slow_timeout
# compute a random backoff time for each slow node and fix it. This ensures that only one slow node will
# create a block in expectation
if self.slow_timeout_backoff is None:
self.slow_timeout_backoff = random.uniform(0, self.n) * 0.5

patience = (2. + EPSILON) * self.expected_rtt + self.slow_timeout_backoff * self.expected_rtt

return patience + ACCUMULATION_TIME

def timeout_over(self, txn):
Expand Down

0 comments on commit df49802

Please sign in to comment.