lbry-sdk/lbrynet/dht/constants.py

62 lines
2.1 KiB
Python
Raw Normal View History

2015-08-20 17:27:15 +02:00
#!/usr/bin/env python
#
# This library is free software, distributed under the terms of
# the GNU Lesser General Public License Version 3, or any later version.
# See the COPYING file included in this archive
#
# The docstrings in this module contain epytext markup; API documentation
# may be created by processing this file with epydoc: http://epydoc.sf.net
""" This module defines the charaterizing constants of the Kademlia network
C{checkRefreshInterval} and C{udpDatagramMaxSize} are implementation-specific
2016-12-14 00:08:29 +01:00
constants, and do not affect general Kademlia operation.
2015-08-20 17:27:15 +02:00
"""
######### KADEMLIA CONSTANTS ###########
#: Small number Representing the degree of parallelism in network calls
alpha = 3
#: Maximum number of contacts stored in a bucket; this should be an even number
k = 8
#: Maximum number of contacts stored in the replacement cache
replacementCacheSize = 8
2015-08-20 17:27:15 +02:00
#: Timeout for network operations (in seconds)
rpcTimeout = 5
2015-08-20 17:27:15 +02:00
# number of rpc attempts to make before a timeout results in the node being removed as a contact
rpcAttempts = 5
2018-07-12 23:24:59 +02:00
# time window to count failures (in seconds)
rpcAttemptsPruningTimeWindow = 600
2015-08-20 17:27:15 +02:00
# Delay between iterations of iterative node lookups (for loose parallelism) (in seconds)
iterativeLookupDelay = rpcTimeout / 2
#: If a k-bucket has not been used for this amount of time, refresh it (in seconds)
2017-03-31 19:32:43 +02:00
refreshTimeout = 3600 # 1 hour
2015-08-20 17:27:15 +02:00
#: The interval at which nodes replicate (republish/refresh) data they are holding
replicateInterval = refreshTimeout
# The time it takes for data to expire in the network; the original publisher of the data
# will also republish the data at this time if it is still valid
2017-03-31 19:32:43 +02:00
dataExpireTimeout = 86400 # 24 hours
2015-08-20 17:27:15 +02:00
2017-03-31 19:32:43 +02:00
tokenSecretChangeInterval = 300 # 5 minutes
2015-08-20 17:27:15 +02:00
######## IMPLEMENTATION-SPECIFIC CONSTANTS ###########
2018-05-29 16:58:24 +02:00
#: The interval for the node to check whether any buckets need refreshing
2017-03-31 19:32:43 +02:00
checkRefreshInterval = refreshTimeout / 5
2015-08-20 17:27:15 +02:00
#: Max size of a single UDP datagram, in bytes. If a message is larger than this, it will
2017-04-10 16:51:49 +02:00
#: be spread across several UDP packets.
2017-03-31 19:32:43 +02:00
udpDatagramMaxSize = 8192 # 8 KB
2015-08-20 17:27:15 +02:00
2018-05-29 16:58:24 +02:00
key_bits = 384
2017-10-25 02:05:30 +02:00
rpc_id_length = 20
protocolVersion = 1