pub struct BlockInfo {
pub height: u64,
pub time: Timestamp,
pub chain_id: String,
}
Fields§
§height: u64
The height of a block is the number of blocks preceding it in the blockchain.
time: Timestamp
Absolute time of the block creation in seconds since the UNIX epoch (00:00:00 on 1970-01-01 UTC).
The source of this is the BFT Time in Tendermint,
which has the same nanosecond precision as the Timestamp
type.
Examples
Using chrono:
use chrono::NaiveDateTime;
let seconds = env.block.time.seconds();
let nsecs = env.block.time.subsec_nanos();
let dt = NaiveDateTime::from_timestamp(seconds as i64, nsecs as u32);
Creating a simple millisecond-precision timestamp (as used in JavaScript):
let millis = env.block.time.nanos() / 1_000_000;
chain_id: String
Trait Implementations§
source§impl<'de> Deserialize<'de> for BlockInfo
impl<'de> Deserialize<'de> for BlockInfo
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<BlockInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<BlockInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl JsonSchema for BlockInfo
impl JsonSchema for BlockInfo
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl PartialEq<BlockInfo> for BlockInfo
impl PartialEq<BlockInfo> for BlockInfo
source§impl Serialize for BlockInfo
impl Serialize for BlockInfo
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more