Skip to main content

hopr_lib/
state.rs

1use std::hash::Hash;
2
3use crate::exports::transport::HoprTransportProcess;
4
5/// An enum representing the current state of the HOPR node.
6///
7/// The states represent granular steps in the node initialization and lifecycle,
8/// providing detailed progress information suitable for UI applications.
9#[atomic_enum::atomic_enum]
10#[derive(PartialEq, Eq, strum::Display, strum::EnumIter)]
11pub enum HoprState {
12    /// Node instance created but not yet started
13    #[strum(to_string = "Node is not yet initialized")]
14    Uninitialized = 0,
15
16    /// Waiting for the node wallet to receive initial funding
17    #[strum(to_string = "Waiting for initial wallet funding")]
18    WaitingForFunds = 1,
19
20    /// Verifying the wallet has sufficient balance to operate
21    #[strum(to_string = "Verifying wallet balance")]
22    CheckingBalance = 2,
23
24    /// Validating network parameters like ticket price and winning probability
25    #[strum(to_string = "Validating network configuration")]
26    ValidatingNetworkConfig = 3,
27
28    /// Subscribing to on-chain account announcements
29    #[strum(to_string = "Subscribing to network announcements")]
30    SubscribingToAnnouncements = 4,
31
32    /// Registering the Safe contract with this node
33    #[strum(to_string = "Registering Safe contract")]
34    RegisteringSafe = 5,
35
36    /// Announcing node multiaddresses on the blockchain
37    #[strum(to_string = "Announcing node on chain")]
38    AnnouncingNode = 6,
39
40    /// Waiting for the node's key binding to appear on-chain
41    #[strum(to_string = "Waiting for on-chain key binding confirmation")]
42    AwaitingKeyBinding = 7,
43
44    /// Initializing internal services (sessions, tickets, transport, channels)
45    #[strum(to_string = "Initializing internal services")]
46    InitializingServices = 8,
47
48    /// Node is fully operational and ready for use
49    #[strum(to_string = "Node is running")]
50    Running = 9,
51
52    /// Node has been shut down
53    #[strum(to_string = "Node has been terminated")]
54    Terminated = 10,
55}
56
57/// Long-running tasks that are spawned by the HOPR node.
58#[derive(Debug, Clone, PartialEq, Eq, Hash, strum::Display, strum::EnumCount)]
59pub enum HoprLibProcess {
60    #[strum(to_string = "transport: {0}")]
61    Transport(HoprTransportProcess),
62    #[cfg(feature = "session-server")]
63    #[strum(to_string = "session server providing the exit node session stream functionality")]
64    SessionServer,
65    #[strum(to_string = "ticket redemption queue driver")]
66    TicketRedemptions,
67    #[strum(to_string = "subscription for on-chain account announcements")]
68    AccountAnnouncements,
69    #[strum(to_string = "subscription for on-chain channel updates")]
70    ChannelEvents,
71    #[strum(to_string = "on received ticket event (winning or rejected)")]
72    TicketEvents,
73}