Module ttd
Expand description
Serde functions for encoding the TTD using a Geth compatible format.
In Go big.Int is marshalled as a JSON number without quotes. Numbers are arbitrary
precision in JSON, so this is valid JSON.
These functions serialize the TTD as a JSON number, if the value fits within u128.
The TTD is parsed from:
- JSON numbers: direct
u64values, or the specific Ethereum mainnet TTD (e.g.,5.875e22if represented as a float). Other floats or negative numbers will error. - JSON strings: these are parsed as
U256(allowing hex or decimal strings).
For non-human-readable formats, the default serde behavior for Option<U256> is used.
Functionsยง
- deserialize
- Deserializes an optional TTD value from JSON number or string.
- deserialize_
json_ ttd_ opt - Supports parsing the TTD as an
Option<u64>, orOption<f64>specifically for the mainnet TTD (5.875e22). - serialize
- Serializes an optional TTD as a JSON number.