mod.rs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2022 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. /// Acceptor class handles the acceptance of inbound socket connections. It's
  19. /// used to start listening on a local socket address, to accept incoming
  20. /// connections and to handle network errors.
  21. pub mod acceptor;
  22. /// Async channel that handles the sending of messages across the network.
  23. /// Public interface is used to create new channels, to stop and start
  24. /// a channel, and to send messages.
  25. ///
  26. /// Implements message functionality and the message subscriber subsystem.
  27. pub mod channel;
  28. /// Handles the creation of outbound connections. Used to establish an outbound
  29. /// connection.
  30. pub mod connector;
  31. /// Hosts are a list of network addresses used when establishing an outbound
  32. /// connection. Hosts are shared across the network through the address
  33. /// protocol. When attempting to connect, a node will loop through addresses in
  34. /// the host store until it finds ones to connect to.
  35. pub mod hosts;
  36. /// Generic publish/subscribe class that can dispatch any kind of message to a
  37. /// subscribed list of dispatchers. Dispatchers subscribe to a single
  38. /// message format of any type. This is a generalized version of the simple
  39. /// publish-subscribe class in system::Subscriber.
  40. ///
  41. /// Message Subsystem also enables the creation of new message subsystems,
  42. /// adding new dispatchers and clearing inactive channels.
  43. ///
  44. /// Message Subsystem maintains a list of dispatchers, which is a generalized
  45. /// version of a subscriber. Pub-sub is called on dispatchers through the
  46. /// functions 'subscribe' and 'notify'. Whereas system::Subscriber only allows
  47. /// messages of a single type, dispatchers can handle any kind of message. This
  48. /// generic message is called a payload and is processed and decoded by the
  49. /// Message Dispatcher.
  50. ///
  51. /// The Message Dispatcher is a class of subscribers that implements a
  52. /// generic trait called Message Dispatcher Interface, which allows us to
  53. /// process any kind of payload as a message.
  54. pub mod message_subscriber;
  55. /// Defines how to decode generic messages as well as implementing the common
  56. /// network messages that are sent between nodes as described by the Protocol
  57. /// submodule.
  58. ///
  59. /// Implements a type called Packet which is the base message type. Packets are
  60. /// converted into messages and passed to an event loop.
  61. pub mod message;
  62. /// P2P provides all core functionality to interact with the peer-to-peer
  63. /// network.
  64. ///
  65. /// Used to create a network, to start and run it, to broadcast messages across
  66. /// all channels, and to manage the channel store.
  67. ///
  68. /// The channel store is a hashmap of channel address that we can use to add and
  69. /// remove channels or check whether a channel is already is in the store.
  70. pub mod p2p;
  71. /// Defines the networking protocol used at each stage in a connection. Consists
  72. /// of a series of messages that are sent across the network at the different
  73. /// connection stages.
  74. ///
  75. /// When a node connects to a network for the first time, it must follow a seed
  76. /// protocol, which provides it with a list of network hosts to connect to. To
  77. /// establish a connection to another node, nodes must send version and version
  78. /// acknowledgement messages. During a connection, nodes continually get address
  79. /// and get-address messages to inform eachother about what nodes are on the
  80. /// network. Nodes also send out a ping and pong message which keeps the network
  81. /// from shutting down.
  82. ///
  83. /// Protocol submodule also implements a jobs manager than handles the
  84. /// asynchronous execution of the protocols.
  85. pub mod protocol;
  86. /// Defines the interaction between nodes during a connection. Consists of an
  87. /// inbound session, which describes how to set up an incoming connection, and
  88. /// an outbound session, which describes setting up an outbound connection. Also
  89. /// describes the seed session, which is the type of connection used when a node
  90. /// connects to the network for the first time. Implements the session trait
  91. /// which describes the common functions across all sessions.
  92. pub mod session;
  93. /// Network configuration settings.
  94. pub mod settings;
  95. /// Network transport implementations.
  96. pub mod transport;
  97. /// Network constants for various validations.
  98. pub mod constants;
  99. pub use acceptor::{Acceptor, AcceptorPtr};
  100. pub use channel::{Channel, ChannelPtr};
  101. pub use connector::Connector;
  102. pub use hosts::{Hosts, HostsPtr};
  103. pub use message::Message;
  104. pub use message_subscriber::MessageSubscription;
  105. pub use p2p::{P2p, P2pPtr};
  106. pub use protocol::{ProtocolBase, ProtocolBasePtr, ProtocolJobsManager, ProtocolJobsManagerPtr};
  107. pub use session::{
  108. Session, SessionBitflag, SessionWeakPtr, SESSION_ALL, SESSION_INBOUND, SESSION_MANUAL,
  109. SESSION_OUTBOUND, SESSION_SEED,
  110. };
  111. pub use settings::{Settings, SettingsPtr};