Skip to main content

Module builder

Module builder 

Source
Expand description

Builder module for the Hopr object. Type-state builder for constructing a Hopr node.

The builder guides construction through a series of mandatory phases:

  1. IdentityHoprBuilderHoprBuilder::with_identity
  2. ConfigurationHoprBuilderWithIdentity::with_config
  3. Component factories — chain API, graph, network, and cover-traffic
  4. Session server (when the session-server feature is enabled) — HoprBuilderConfigured::with_session_server
  5. Buildbuild_edge for an entry/exit node or build_full for a relay node with ticket management.

§Example

use hopr_lib::{config::HoprLibConfig, builder::{HoprBuilder, ChainKeypair, OffchainKeypair, Keypair}};

let chain_key = ChainKeypair::random();
let offchain_key = OffchainKeypair::random();
let config = HoprLibConfig::default();

let builder = HoprBuilder
    .with_identity(&chain_key, &offchain_key)
    .with_config(config)
    .with_chain_api(|_ctx| { /* ... */ todo!() })
    .with_graph(|_ctx| { /* ... */ todo!() })
    .with_network(|_ctx| Box::pin(async { /* ... */ todo!() }))
    .with_cover_traffic(|_ctx| { /* ... */ todo!() });

Macros§

impl_build_methods 🔒

Structs§

BuildCtx
Context available to factory closures during the build step.
ChainKeypair
Represents a keypair consisting of a secp256k1 private and public key
HoprBuilder
Initial builder — forces with_identity first.
HoprBuilderConfigured
Configured builder accepting factory closures for components.
HoprBuilderWithIdentity
Builder with identity set — forces with_config next.
HoprBuilderWithSession
Builder with a session server attached. Has build_edge / build_full.
METRIC_HOPR_LIB_VERSION 🔒
METRIC_HOPR_NODE_INFO 🔒
METRIC_PROCESS_START_TIME 🔒
OffchainKeypair
Represents a keypair consisting of an Ed25519 private and public key
PreHopr 🔒

Traits§

Keypair
Represents a generic key pair The keypair contains a private key and public key. Must be comparable in constant time and zeroized on drop.

Functions§

pre_build_inner 🔒

Type Aliases§

AsyncFactory 🔒
Factory 🔒
Type-erased factory closure producing T from a BuildCtx reference.