1
0

const.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # The contents of this file are subject to the BitTorrent Open Source License
  2. # Version 1.1 (the License). You may not copy or use this file, in either
  3. # source code or executable form, except in compliance with the License. You
  4. # may obtain a copy of the License at http://www.bittorrent.com/license/.
  5. #
  6. # Software distributed under the License is distributed on an AS IS basis,
  7. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  8. # for the specific language governing rights and limitations under the
  9. # License.
  10. # magic id to use before we know a peer's id
  11. NULL_ID = 20 * '\0'
  12. # Kademlia "K" constant, this should be an even number
  13. K = 8
  14. # SHA1 is 160 bits long
  15. HASH_LENGTH = 160
  16. # checkpoint every this many seconds
  17. CHECKPOINT_INTERVAL = 60 * 5 # five minutes
  18. # how often to find our own nodes
  19. FIND_CLOSE_INTERVAL = 60 * 15 # fifteen minutes
  20. ### SEARCHING/STORING
  21. # concurrent krpc calls per find node/value request!
  22. CONCURRENT_REQS = K
  23. # how many hosts to post to
  24. STORE_REDUNDANCY = 3
  25. ### ROUTING TABLE STUFF
  26. # how many times in a row a node can fail to respond before it's booted from the routing table
  27. MAX_FAILURES = 3
  28. # never ping a node more often than this
  29. MIN_PING_INTERVAL = 60 * 15 # fifteen minutes
  30. # refresh buckets that haven't been touched in this long
  31. BUCKET_STALENESS = 60 * 15 # fifteen minutes
  32. ### KEY EXPIRER
  33. # time before expirer starts running
  34. KEINITIAL_DELAY = 15 # 15 seconds - to clean out old stuff in persistent db
  35. # time between expirer runs
  36. KE_DELAY = 60 * 5 # 5 minutes
  37. # expire entries older than this
  38. KE_AGE = 60 * 30 # 30 minutes
  39. ## krpc errback codes
  40. KRPC_TIMEOUT = 20
  41. KRPC_ERROR = 1
  42. KRPC_ERROR_METHOD_UNKNOWN = 2
  43. KRPC_ERROR_RECEIVED_UNKNOWN = 3
  44. KRPC_ERROR_TIMEOUT = 4
  45. KRPC_SOCKET_ERROR = 5
  46. KRPC_CONNECTION_CACHE_TIME = KRPC_TIMEOUT * 2
  47. ## krpc erorr response codes
  48. KERR_ERROR = (201, "Generic Error")
  49. KERR_SERVER_ERROR = (202, "Server Error")
  50. KERR_PROTOCOL_ERROR = (203, "Protocol Error")
  51. KERR_METHOD_UNKNOWN = (204, "Method Unknown")
  52. KERR_INVALID_ARGS = (205, "Invalid Argements")
  53. KERR_INVALID_TOKEN = (206, "Invalid Token")