pub struct Ledger(/* private fields */);
Expand description
Ledger retrieves information about the current ledger.
For more details about the ledger and the ledger header that the values in the Ledger are derived from, see:
§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.
For more details see:
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§
Source§impl Ledger for Ledger
Available on crate feature testutils
only.
impl Ledger for Ledger
testutils
only.Source§fn set(&self, li: LedgerInfo)
fn set(&self, li: LedgerInfo)
Source§fn set_protocol_version(&self, protocol_version: u32)
fn set_protocol_version(&self, protocol_version: u32)
Source§fn set_sequence_number(&self, sequence_number: u32)
fn set_sequence_number(&self, sequence_number: u32)
Source§fn set_timestamp(&self, timestamp: u64)
fn set_timestamp(&self, timestamp: u64)
Source§fn set_network_id(&self, network_id: [u8; 32])
fn set_network_id(&self, network_id: [u8; 32])
Source§fn set_base_reserve(&self, base_reserve: u32)
fn set_base_reserve(&self, base_reserve: u32)
Source§fn set_min_temp_entry_ttl(&self, min_temp_entry_ttl: u32)
fn set_min_temp_entry_ttl(&self, min_temp_entry_ttl: u32)
Source§fn set_min_persistent_entry_ttl(&self, min_persistent_entry_ttl: u32)
fn set_min_persistent_entry_ttl(&self, min_persistent_entry_ttl: u32)
Source§fn set_max_entry_ttl(&self, max_entry_ttl: u32)
fn set_max_entry_ttl(&self, max_entry_ttl: u32)
Source§fn get(&self) -> LedgerInfo
fn get(&self) -> LedgerInfo
Source§fn with_mut<F>(&self, f: F)where
F: FnMut(&mut LedgerInfo),
fn with_mut<F>(&self, f: F)where
F: FnMut(&mut LedgerInfo),
Auto Trait Implementations§
impl Freeze for Ledger
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
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>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
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>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more