Skip to main content

hopr_strategy/
lib.rs

1//! This crate contains all the Strategies for HOPRd.
2//! Strategies are vital for (partial) automation of ticket and HOPR channel operations
3//! during node runtime.
4//!
5//! - [passive strategy](crate::strategy::MultiStrategy)
6//! - auto funding strategy (`auto_funding` module, feature `strategy-auto-funding`)
7//! - auto redeeming strategy (`auto_redeeming` module, feature `strategy-auto-redeeming`)
8//! - closure finalizer (`channel_finalizer` module, feature `strategy-closure-finalizer`)
9//! - channel lifecycle strategy (feature `strategy-channel-lifecycle`)
10//! - [multiple strategy chains](crate::strategy)
11//!
12//! Individual strategies are gated behind Cargo features.
13//!
14//! ## Configuring strategies in HOPRd
15//!
16//! There are two ways of configuring strategies in HOPRd: via CLI and via a YAML config file.
17//!
18//! The configuration through CLI allows only fairly primitive single-strategy setting, through the `defaultStrategy`
19//! parameter. It can be set to any of the above strategies, however, the strategy parameters are not further
20//! configurable via the CLI and will always have their default values.
21//! In addition, if the ` disableTicketAutoRedeem ` CLI argument is `false`, the default Auto Redeem strategy is added
22//! to the strategy configured via the `defaultStrategy` argument (they execute together as Multi strategy).
23//!
24//! For more complex strategy configurations, the YAML configuration method is recommended via the `strategy` YAML
25//! section. In this case, the top-most strategy is always assumed to be Multi strategy:
26//!
27//! ```yaml
28//! strategy:
29//!   allow_recursive: true
30//!   execution_interval: 60
31//!   strategies:
32//!     - !AutoFunding
33//!       funding_amount: 20
34//! ```
35
36/// Shared serde default helpers used across multiple strategy configs.
37#[cfg(feature = "strategy-auto-redeeming")]
38pub(crate) fn just_true() -> bool {
39    true
40}
41#[cfg(feature = "strategy-auto-redeeming")]
42pub(crate) fn just_false() -> bool {
43    false
44}
45
46#[cfg(feature = "strategy-auto-funding")]
47pub mod auto_funding;
48#[cfg(feature = "strategy-auto-redeeming")]
49pub mod auto_redeeming;
50#[cfg(feature = "strategy-closure-finalizer")]
51pub mod channel_finalizer;
52#[cfg(feature = "strategy-channel-lifecycle")]
53pub mod channel_lifecycle;
54pub mod errors;
55pub mod strategy;