Crate hopr_lib

Source
Expand description

HOPR library creating a unified Hopr object that can be used on its own, as well as integrated into other systems and libraries.

The Hopr object is standalone, meaning that once it is constructed and run, it will perform its functionality autonomously. The API it offers serves as a high-level integration point for other applications and utilities, but offers a complete and fully featured HOPR node stripped from top level functionality such as the REST API, key management…

The intended way to use hopr_lib is for a specific tool to be built on top of it, should the default hoprd implementation not be acceptable.

For most of the practical use cases, the hoprd application should be a preferable choice.

Modules§

config
Configuration-related public types
constants
Various public constants.
errors
Lists all errors thrown from this library.

Structs§

AccountEntry
Represents a node announcement entry on the block chain. This contains node’s public key and optional announcement information (multiaddress, block number).
AcknowledgedTicket
Contains acknowledgment information and the respective ticket
Acknowledgement
Represents packet acknowledgement
Address
Represents an Ethereum address
AnnouncementData
Structure containing data used for an on-chain announcement. That is the decapsulated multiaddress (with the /p2p/{peer_id} suffix removed) and optional KeyBinding (an announcement can be done with key bindings or without)
ApplicationData
Represents the received decrypted packet carrying the application-layer data.
AtomicHoprState
A wrapper around HoprState which can be safely shared between threads.
Balance
Represents balance of some coin or token.
ChainNetwork
Holds all information about the protocol network to be used by the client
ChannelEntry
Overall description of a channel
CloseChannelResult
DateTime
ISO 8601 combined date and time with time zone.
EthereumChallenge
Represents and Ethereum challenge. This is a one-way encoding of the secp256k1 curve point to an Ethereum address.
GraphExportConfig
Configuration for the DOT export of the ChannelGraph.
HalfKeyChallenge
Represents a challenge for the half-key in Proof of Relay. Half-key challenge is equivalent to a secp256k1 curve point. Therefore, HalfKeyChallenge can be obtained from a HalfKey.
Hopr
HOPR main object providing the entire HOPR node functionality
HoprIncomingSession
Wrapper for incoming Session along with other information extracted from the Start protocol during the session establishment.
HoprOffchainKeypair
Represents a keypair consisting of an Ed25519 private and public key
HoprSession
HoprSessionId
Unique ID of a specific session.
HoprSocket
Represents the socket behavior of the hopr-lib spawned Hopr object.
HostConfig
Configuration of the listening host.
KeyBinding
Holds the signed binding of the chain key and the packet key.
Multiaddr
Representation of a Multiaddr.
NetworkContractAddresses
NoSumSMA
Basic implementation of Simple Moving Average (SMA).
OpenChannelResult
PeerId
Identifier of a peer of the network.
ProtocolsConfig
The entire on-chain protocol configuration containing the information about usable networks and chains.
RedeemableTicket
Represents a winning ticket that can be successfully redeemed on chain.
SerializableLog
A type containing selected fields from the eth_getLogs RPC calls.
SessionClientConfig
Configuration for the session.
SingleSumSMA
Basic implementation of Simple Moving Average (SMA).
TagBloomFilter
Bloom filter for packet tags to detect packet replays.
Ticket
Contains the overall description of a ticket with a signature.
TicketBuilder
Builder for Ticket and VerifiedTicket.
TicketStatistics
Ticket statistics data exposed by the ticket mechanism.
TransferableWinningTicket
Represents a ticket that could be transferred over the wire and independently verified again by the other party.
UnacknowledgedTicket
Represents a VerifiedTicket with an unknown other part of the HalfKey. Once the other HalfKey is known (forming a Response), it can be acknowledged.
Utc
The UTC time zone. This is the most efficient time zone when you don’t need the local time. It is also used as an offset (which is also a dummy type).
VerifiedTicket
Holds a ticket that has been already verified. This structure guarantees that Ticket::get_hash() of VerifiedTicket::verified_ticket() is always equal to VerifiedTicket::verified_hash

Enums§

AccountType
Type of the node account.
AcknowledgedTicketStatus
Status of the acknowledged ticket.
BalanceType
Represents a type of the balance: native or HOPR tokens.
ChainActionsError
Enumerates all Chain Actions related errors.
ChannelChange
Enumerates possible changes on a channel entry update
ChannelDirection
Describes a direction of node’s own channel. The direction of a channel that is not own is undefined.
ChannelStatus
Describes status of a channel
CoreTypesError
Enumeration of all core type related errors.
EnvironmentType
Types of HOPR network environments.
GeneralError
Listing of some general re-usable errors
Health
Network health represented with colors, where green is the best and red is the worst possible observed nework quality.
HoprLibProcesses
Enum differentiator for loop component futures.
HoprState
An enum representing the current state of the HOPR node
HoprTransportError
Errors produced by the crate.
HostType
Enumeration of possible host types.
IpProtocol
Lists some of the IP protocols.
NetworkingError
Errors that can be generated by the crate.
PendingAcknowledgement
Contains either unacknowledged ticket if we’re waiting for the acknowledgement as a relayer or information if we wait for the acknowledgement as a sender.
ProtocolError
Errors generated by the crate.
RoutingOptions
Represents routing options in a mixnet with a maximum number of hops.
SessionCapability
Capabilities of a session.
SessionTarget
Defines what should happen with the data at the recipient where the data from the established session are supposed to be forwarded to some target.
Strategy
Lists all possible strategies with their respective configurations.

Constants§

ALWAYS_WINNING
Encodes 100% winning probability
DEFAULT_APPLICATION_TAG
Represent a default application tag if none is specified in send_packet.
DEFAULT_MAXIMUM_INCOMING_TICKET_WIN_PROB
Default maximum incoming ticket winning probability, above which tickets will not be accepted due to privacy.
DEFAULT_MINIMUM_INCOMING_TICKET_WIN_PROB
Default required minimum incoming ticket winning probability
DEFAULT_OUTGOING_TICKET_WIN_PROB
Default ticket winning probability that will be printed on outgoing tickets
INTERMEDIATE_HOPS
Number of intermediate hops: 3 relayers and 1 destination
LOWEST_POSSIBLE_WINNING_PROB
The lowest possible ticket winning probability due to SC representation limit.
NEVER_WINNING
Encodes 0% winning probability
PAYLOAD_SIZE
Maximum size of the packet payload in bytes.
RESERVED_TAG_UPPER_LIMIT
SESSION_USABLE_MTU_SIZE
Inner MTU size of what the HOPR payload can take (payload - peer_id - application_tag)

Traits§

AsUnixTimestamp
A trait that adds extension method to represent a time object as Duration since Unix epoch.
BytesEncodable
Represents a type that can be encoded to/decoded from a fixed sized byte array of size N. This requires processing and memory allocation to represent the type in binary encoding.
BytesRepresentable
Represents a type that is already internally represented by a fixed size byte array, and therefore requires no memory allocation to represent the type in binary encoding.
HoprSessionReactor
Interface representing the HOPR server behavior for each incoming session instance supplied as an argument.
IntoEndian
Extension trait for fixed size numbers to allow conversion to/from endian representations.
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.
SMA
Simple Moving Average trait.
SaturatingSub
A trait that adds extension method to perform saturated substractions on SystemTime instances.
SendMsg
ToHex
A generic type that can be converted to a hexadecimal string.
UnitaryFloatOps
Allows type to be multiplied and divided by a float in range [0.0, 1.0].

Functions§

chain_events_to_transport_events
Creates a pipeline that chains the indexer-generated data, processes them into the individual components and creates a filtered output stream that is fed into the transport layer swarm.
decapsulate_multiaddress
Decapsulates the multiaddress (= strips the /p2p/<peer_id> suffix). If it is already decapsulated, the function is an identity.
f64_approx_eq
Approximately compares two double-precision floats.
f64_to_win_prob
Encodes [0.0f64, 1.0f64] to [0x00000000000000, 0xffffffffffffff]
generate_channel_id
Generates channel ID hash from source and destination addresses.
looks_like_domain
Check whether the string looks like a valid domain.
transfer_session
Convenience function to copy data in both directions between a Session and arbitrary async IO stream. This function is only available with Tokio and will panic with other runtimes.
win_prob_to_f64
Decodes [0x00000000000000, 0xffffffffffffff] to [0.0f64, 1.0f64]

Type Aliases§

EncodedWinProb
Winning probability encoded in 7-byte representation
ServiceId
Describes a node service target. These are specialized SessionTargets that are local to the Exit node and have different purposes, such as Cover Traffic.
Tag
Tags are currently 16-bit unsigned integers
U256

Attribute Macros§

async_trait