pub struct BlockTime(/* private fields */);Expand description
A Bitcoin block timestamp.
Each block contains a Unix time timestamp. In addition to serving as a source of variation for the block hash, they also make it more difficult for an adversary to manipulate the block chain.
A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours. “Network-adjusted time” is the median of the timestamps returned by all nodes connected to you. As a result block timestamps are not exactly accurate, and they do not need to be. Block times are accurate only to within an hour or two.
Implementations§
Source§impl BlockTime
impl BlockTime
Sourcepub fn from_hex(s: &str) -> Result<Self, PrefixedHexError>
pub fn from_hex(s: &str) -> Result<Self, PrefixedHexError>
Constructs a new BlockTime from a prefixed hex string.
§Errors
If the input string is not a valid hex representation of a blocktime or it does not include
the 0x prefix.
Sourcepub fn from_unprefixed_hex(s: &str) -> Result<Self, UnprefixedHexError>
pub fn from_unprefixed_hex(s: &str) -> Result<Self, UnprefixedHexError>
Constructs a new BlockTime from an unprefixed hex string.
§Errors
If the input string is not a valid hex representation of a blocktime or if it includes the
0x prefix.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for BlockTime
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for BlockTime
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for BlockTime
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BlockTime
serde only.