mod.rs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2023 Dyne.org foundation
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /// Defines how to decode generic messages as well as implementing the
  19. /// common network messages that are sent between nodes as described
  20. /// by the [`protocol`] submodule.
  21. ///
  22. /// Implements a type called `Packet` which is the base message type.
  23. /// Packets are converted into messages and passed to an event loop.
  24. pub mod message;
  25. pub use message::Message;
  26. /// Generic publish/subscribe class that can dispatch any kind of message
  27. /// to a subscribed list of dispatchers. Dispatchers subscribe to a single
  28. /// message format of any type. This is a generalized version of the simple
  29. /// publish-subscribe class in system::Subscriber.
  30. ///
  31. /// Message Subsystem also enables the creation of new message subsystems,
  32. /// adding new dispatchers and clearing inactive channels.
  33. ///
  34. /// Message Subsystem maintains a list of dispatchers, which is a generalized
  35. /// version of a subscriber. Pub-sub is called on dispatchers through the
  36. /// functions `subscribe` and `notify`. Whereas system::Subscriber only allows
  37. /// messages of a single type, dispatchers can handle any kind of message. This
  38. /// generic message is called a payload and is processed and decoded by the
  39. /// Message Dispatcher.
  40. ///
  41. /// The Message Dispatcher is a class of subscribers that implement a generic
  42. /// trait called Message Dispatcher Interface, which allows us to process any
  43. /// kind of payload as a message.
  44. pub mod message_subscriber;
  45. pub use message_subscriber::MessageSubscription;
  46. /// Network transports, holds implementations of pluggable transports.
  47. /// Exposes agnostic dialers and agnostic listeners.
  48. pub mod transport;
  49. /// Hosts are a list of network addresses used when establishing outbound
  50. /// connections. Hosts are shared across the network through the address
  51. /// protocol. When attempting to connect, a node will loop through addresses
  52. /// in the hosts store until it finds ones to connect to.
  53. pub mod hosts;
  54. /// Async channel that handles the sending of messages across the network.
  55. /// Public interface is used to create new channels, to stop and start a
  56. /// channel, and to send messages.
  57. pub mod channel;
  58. pub use channel::ChannelPtr;
  59. /// P2P provides all core functionality to interact with the P2P network.
  60. ///
  61. /// Used to create a network, to start and run it, to broadcast messages
  62. /// across all channels, and to manage the channel store.
  63. ///
  64. /// The channel store is a hashmap of channel addresses that we can use
  65. /// to add and remove channels or check whether a channel is already in
  66. /// the store.
  67. #[macro_use]
  68. pub mod p2p;
  69. pub use p2p::{P2p, P2pPtr};
  70. /// Defines the networking protocol used at each stage in a connection.
  71. /// Consists of a series of messages that are sent across the network at
  72. /// the different connection stages.
  73. ///
  74. /// When a node connects to a network for the first time, it must follow
  75. /// a seed protocol, which provides it with a list of network hosts to
  76. /// connect to. To establish a connection to another node, nodes must send
  77. /// version and version acknowledgement messages. During a connection, nodes
  78. /// continually get address and get-address messages to inform each other
  79. /// about what nodes are on the network. Nodes also send out a ping and pong
  80. /// message which keeps the network from shutting down.
  81. ///
  82. /// Protocol submodule also implements a jobs manager that handles the
  83. /// asynchronous execution of the protocols.
  84. pub mod protocol;
  85. pub use protocol::{
  86. protocol_base::{ProtocolBase, ProtocolBasePtr},
  87. protocol_jobs_manager::{ProtocolJobsManager, ProtocolJobsManagerPtr},
  88. };
  89. /// Defines the interaction between nodes during a connection.
  90. /// Consists of an inbound session, which describes how to set up an
  91. /// incoming connection, and an outbound session, which describes setting
  92. /// up an outbound connection. Also describes the sesd session, which is
  93. /// the type of connection used when a node connects to the network for
  94. /// the first time. Implements the `Session` trait which describes the
  95. /// common functions across all sessions.
  96. pub mod session;
  97. pub use session::SESSION_ALL;
  98. /// Handles the acceptance of inbound socket connections.
  99. /// Used to start listening on a local socket, to accept incoming connections,
  100. /// and to handle network errors.
  101. pub mod acceptor;
  102. /// Handles the creation of outbound connections.
  103. /// Used to establish an outbound connection.
  104. pub mod connector;
  105. /// Network configuration settings. This holds the configured P2P instance
  106. /// behaviour and is controlled by clients of this API.
  107. pub mod settings;
  108. pub use settings::Settings;