Struct soroban_sdk::ledger::Ledger
source · pub struct Ledger(/* private fields */);
Expand description
Ledger retrieves information about the current ledger.
Examples
use soroban_sdk::Env;
let ledger = env.ledger();
let protocol_version = ledger.protocol_version();
let sequence = ledger.sequence();
let timestamp = ledger.timestamp();
let network_id = ledger.network_id();
Implementations§
source§impl Ledger
impl Ledger
sourcepub fn protocol_version(&self) -> u32
pub fn protocol_version(&self) -> u32
Returns the version of the protocol that the ledger created with.
sourcepub fn sequence(&self) -> u32
pub fn sequence(&self) -> u32
Returns the sequence number of the ledger.
The sequence number is a unique number for each ledger that is sequential, incremented by one for each new ledger.
sourcepub fn timestamp(&self) -> u64
pub fn timestamp(&self) -> u64
Returns a unix timestamp for when the ledger was closed.
The timestamp is the number of seconds, excluding leap seconds, that have elapsed since unix epoch. Unix epoch is January 1st, 1970, at 00:00:00 UTC.
sourcepub fn network_id(&self) -> BytesN<32>
pub fn network_id(&self) -> BytesN<32>
Returns the network identifier.
This is SHA-256 hash of the network passphrase, for example for the Public Network this returns:
SHA256(Public Global Stellar Network ; September 2015)
Returns for the Test Network:
SHA256(Test SDF Network ; September 2015)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Ledger
impl !Send for Ledger
impl !Sync for Ledger
impl Unpin for Ledger
impl !UnwindSafe for Ledger
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
§impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W) ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X) ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.