Skip to main content

Module ttd

Module ttd 

Expand description

Serde functions for encoding terminal total difficulty (TTD) using a geth-compatible format.

Human-readable serializers emit values that fit in u128 as unquoted decimal numbers. Larger values use U256’s standard human-readable representation, a quoted hex string. Most values above u64::MAX through u128::MAX therefore do not round-trip through this helper: serialization emits an unquoted number that deserialization rejects. Use a quoted decimal or hex representation at the wire boundary when those values must round-trip.

Human-readable deserializers accept null, hex or decimal strings parsed as U256, JSON integers up to u64::MAX, and geth’s unquoted Ethereum mainnet TTD (58750000000000000000000). serde_json represents larger JSON numbers as f64, so nearby integer literals that round to the same float are also normalized to that mainnet value; other numbers outside the u64 range are rejected.

For non-human-readable formats, the default serde behavior for Option<U256> is used.

Functions§

deserialize
Deserializes an optional TTD using the formats described in the module documentation.
deserialize_json_ttd_opt
Compatibility alias for deserialize.
serialize
Serializes an optional TTD using the format described in the module documentation.