Struct cosmwasm_std::BlockInfo
source · 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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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 schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. 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 for BlockInfo
impl PartialEq for BlockInfo
impl Eq for BlockInfo
impl StructuralPartialEq for BlockInfo
Auto Trait Implementations§
impl Freeze for BlockInfo
impl RefUnwindSafe for BlockInfo
impl Send for BlockInfo
impl Sync for BlockInfo
impl Unpin for BlockInfo
impl UnwindSafe for BlockInfo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more