Struct taple_core::Taple
source · pub struct Taple<M: DatabaseManager<C>, C: DatabaseCollection> { /* private fields */ }
Expand description
Structure representing a node of a TAPLE network.
A node must be instantiated using the Taple::new
method, which requires a set
of configuration parameters in order to be properly initialized.
Implementations§
source§impl<M: DatabaseManager<C> + 'static, C: DatabaseCollection + 'static> Taple<M, C>
impl<M: DatabaseManager<C> + 'static, C: DatabaseCollection + 'static> Taple<M, C>
sourcepub fn peer_id(&self) -> Option<PeerId>
pub fn peer_id(&self) -> Option<PeerId>
Returns the [PeerId] of the node is available. This ID is the identifier of the node at the network level. None can only be get if the node has not been started yet.
sourcepub fn public_key(&self) -> Option<Vec<u8>>
pub fn public_key(&self) -> Option<Vec<u8>>
Returns the public key (bytes format) of the node is available. None can only be get if the node has not been started yet.
sourcepub fn controller_id(&self) -> Option<String>
pub fn controller_id(&self) -> Option<String>
Returns the controller ID of the node is available. This ID is the identifier of the node at the protocol level. None can only be get if the node has not been started yet.
sourcepub fn get_api(&self) -> NodeAPI
pub fn get_api(&self) -> NodeAPI
This methods allows to get the API of the node. The API can be get as many time as desired. The API is the only method to interact with a node at the user level.
sourcepub fn get_notification_handler(&self) -> NotificationHandler
pub fn get_notification_handler(&self) -> NotificationHandler
This method allows to get an instance of NotificationHandler. This component is used by the node to report any important events that have occurred, for example the creation of new subjects. The component behaves similar to a channel receiver; users only have to call the NotificationHandler::receive method to start receiving notifications.
sourcepub fn get_shutdown_manager(&self) -> TapleShutdownManager
pub fn get_shutdown_manager(&self) -> TapleShutdownManager
This method allows to get the receiver of the shutdown channel used by the node. This can be used by the user/client to detect when the node has emmited the signal to .
sourcepub fn new(settings: TapleSettings, database: M) -> Self
pub fn new(settings: TapleSettings, database: M) -> Self
Main and unique method to create an instance of a TAPLE node.
sourcepub async fn start(&mut self) -> Result<(), Error>
pub async fn start(&mut self) -> Result<(), Error>
This method initializes a TAPLE node, generating each of its internal components and allowing subsequent interaction with the node. Each of the aforementioned components is executed in its own Tokyo task, allowing the method to return the control flow once its execution is finished.
Possible results
If the process is successful, the method will return Ok(())
.
An error will be returned only if it has not been possible to generate the necessary data
for the initialization of the components, mainly due to problems in the initial configuration.
Panics
This method panics if it has not been possible to generate the network layer.