Skip to main content

Crate stratum

Crate stratum 

Source

Re-exports§

pub use error::InternalError;
pub use error::Result;
pub use error::StratumError;
pub use error::StratumErrorResponse;
pub use message::Id;
pub use message::Message;
pub use method::Authorize;
pub use method::Configure;
pub use method::ConfigureResponse;
pub use method::Notify;
pub use method::Reconnect;
pub use method::SetDifficulty;
pub use method::Submit;
pub use method::Subscribe;
pub use method::SubscribeResponse;
pub use method::SuggestDifficulty;

Modules§

error
message
method

Structs§

Difficulty
Difficulty is a fraught metric. It is derived from the network target, where the difficulty equals the current network target divided by the network target defined in the genesis block. The target principally represents a 256-bit number but the block header contains a compact representation called nbits (or CompactTarget). This is inherently lossy. Furthermore difficulty has made itself into the stratum protocol to define the target (inverse of difficulty) a miner’s share has to meet. It is used to tune the frequency of a miner’s share submission and for accounting how much work has been completed. This struct aims to define it’s edges and make it easier to work with but it is inherently lossy and imprecise. If someone stumbles accross this comment and sees a better way to reconcile these different types, please let me know.
Extranonce
Extranonce bytes with hex encoding
JobId
Job identifier (hex-encoded u64)
MerkleNode
Stratum uses the the natural big-endian hex encoding of a hash but for some reason all double sha256d::Hash are displayed in little-endian hex in Bitcoin. To ensure correct serialization/deserialization and display this wrapper type was created.
Nbits
Compact target (nBits) from block header
Nonce
32-bit nonce (hex-encoded)
Ntime
Block timestamp (hex-encoded u32)
PrevHash
Previous block hash
Username
Worker identity with Bitcoin address parsing
Version
Block version with bitmask operations

Constants§

MAX_MESSAGE_SIZE

Functions§

format_si
Format a value with SI prefixes (K, M, G, T, P, …)
merkle_branches
Constructs the merkle branches from all non-coinbase transactions that should be included in the block.
merkle_root
Calculates the merkle root by reassembling the coinbase transaction and rebuilding the merkle tree from the merkle branches. This is definitely a target for some optimization in the future.
parse_si
Parse SI-prefixed values (e.g., “1.5 TH/s”)