1
0

Janitor.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Janitor_H
  16. #define Janitor_H
  17. #include "crypto/random/Random.h"
  18. #include "dht/Address.h"
  19. #include "dht/dhtcore/RouterModule.h"
  20. #include "dht/dhtcore/SearchRunner.h"
  21. #include "dht/dhtcore/NodeStore.h"
  22. #include "dht/dhtcore/RumorMill.h"
  23. #include "memory/Allocator.h"
  24. #include "util/events/EventBase.h"
  25. #include "util/log/Log.h"
  26. #include "util/Linker.h"
  27. Linker_require("dht/dhtcore/Janitor.c")
  28. #include <stdint.h>
  29. struct Janitor
  30. {
  31. /**
  32. * Externally accessible RumorMill.
  33. * Used for direct peers and search results that are closer than the responder.
  34. */
  35. struct RumorMill* externalMill;
  36. /**
  37. * High priority RumorMill.
  38. * Used to discover new links to nodes we already know about.
  39. */
  40. struct RumorMill* linkMill;
  41. /**
  42. * Low priority RumorMill.
  43. * Used to discover new nodes.
  44. */
  45. struct RumorMill* nodeMill;
  46. /** Just used to keep track of nodes that we need to check on for DHT health. */
  47. struct RumorMill* dhtMill;
  48. /**
  49. * The number of milliseconds after a path has been (successfully) pinged which it will
  50. * not be pinged again.
  51. */
  52. #define Janitor_PATH_QUIET_TIME_MILLISECONDS 30000
  53. int64_t pathQuietTimeMilliseconds;
  54. /** The number of milliseconds between attempting local maintenance searches. */
  55. #define Janitor_LOCAL_MAINTENANCE_MILLISECONDS_DEFAULT 1000
  56. uint64_t localMaintainenceMilliseconds;
  57. /**
  58. * The number of milliseconds to pass between global maintainence searches.
  59. * These are searches for random targets which are used to discover new nodes.
  60. */
  61. #define Janitor_GLOBAL_MAINTENANCE_MILLISECONDS_DEFAULT 30000
  62. uint64_t globalMaintainenceMilliseconds;
  63. };
  64. struct Janitor* Janitor_new(struct RouterModule* routerModule,
  65. struct NodeStore* nodeStore,
  66. struct SearchRunner* searchRunner,
  67. struct RumorMill* rumorMill,
  68. struct Log* logger,
  69. struct Allocator* alloc,
  70. struct EventBase* eventBase,
  71. struct Random* rand);
  72. #endif