Expand description
§Parsing, Serializing, and Message Type Identification
Provides logic to convert raw Stratum V2 (Sv2) message data into Rust types, as well as logic
to handle conversions among Sv2 rust types. The crate is no_std compatible by default.
Most of the logic on this module is tightly coupled with the binary_sv2 crate.
§Responsibilities
- Parsing: Converts raw Sv2 message bytes into Rust enums (
CommonMessages,Mining, etc.). - Serialization: Converts Rust enums back into binary format for transmission.
- Protocol Abstraction: Separates logic for different Sv2 subprotocols, ensuring modular and extensible design.
- Message Metadata: Identifies message types and channel bits for routing and processing.
§Supported Subprotocols
- Common Messages: Shared across all Sv2 roles.
- Template Distribution: Handles block templates updates and transaction data.
- Job Declaration: Manages custom mining job declarations, transactions, and solutions.
- Mining Protocol: Manages standard mining communication (e.g., job dispatch, shares submission).
Re-exports§
pub use error::ParserError;
Modules§
Structs§
- Tlv
- A single TLV (Type-Length-Value) field.
Enums§
- AnyMessage
- A parser of all possible SV2 messages
- Common
Message Types - A list of 8-bit message type variants that are common to all Sv2 subprotocols
- Common
Messages - Common Sv2 protocol messages used across all subprotocols.
- Extension
Error - Errors that can occur when working with TLV extension fields.
- Extensions
- Extensions protocol messages for negotiating optional protocol features.
- Extensions
Negotiation - Extensions Negotiation protocol messages (extension_type=0x0001).
- Extensions
Negotiation Types - Extension message types enum for Extensions Negotiation (extension_type=0x0001)
- JobDeclaration
- A parser of messages of Job Declaration subprotocol, to be used for parsing raw messages
- JobDeclaration
Types - A list of 8-bit message type variants under Job Declaration subprotocol
- Mining
- Mining subprotocol messages: categorization, encapsulation, and parsing.
- Mining
Device Messages - A parser of messages that a Mining Device could send
- Mining
Types - A list of 8-bit message type variants under Mining subprotocol
- Template
Distribution - A parser of messages of Template Distribution subprotocol, to be used for parsing raw messages
- Template
Distribution Types - A list of 8-bit message type variants under Template Distribution subprotocol
- TlvError
- Generic errors that can occur during TLV field encoding and decoding.
- TlvList
- A collection of TLV fields that can be used for both parsing and building.
- User
Identity Error - Errors specific to the Worker-Specific Hashrate Tracking extension.
Constants§
- TLV_
HEADER_ SIZE - TLV header size in bytes (3 bytes Type + 2 bytes Length)
Traits§
- IsSv2
Message - A trait that every Sv2 message parser must implement. It helps parsing from Rust types to raw messages.
- TlvField
- Trait for types that can be encoded/decoded as TLV fields.
Functions§
- message_
type_ to_ name - Converts a message type number to a human-readable name
- parse_
message_ frame_ with_ tlvs - Single entry point for parsing any SV2 protocol message frame with TLV support.