Struct thor::wallet::SpendingCounter
source · pub struct SpendingCounter(u32);
Expand description
Spending counter associated to an account.
every time the owner is spending from an account, the counter is incremented. A matching counter needs to be used in the spending phase to make sure we have non-replayability of a transaction.
Note that the leading LANES_BITS bits are used to codify the implicit lane.
Tuple Fields§
§0: u32
Implementations§
source§impl SpendingCounter
impl SpendingCounter
pub fn lane(self) -> usize
pub fn unlaned_counter(self) -> u32
pub fn new(lane: usize, counter: u32) -> Result<SpendingCounter, Error>
pub fn zero() -> SpendingCounter
sourcepub fn increment(self) -> SpendingCounter
pub fn increment(self) -> SpendingCounter
Increment the counter within it own lane. the lane of where this counter apply, cannot change through the incrementation procedure
if the counter bits overflow, it will automatically be wrapped, so that the lane remains identical
pub fn increment_nth(self, n: u32) -> SpendingCounter
pub fn to_bytes(self) -> [u8; 4]
pub fn from_bytes(bytes: [u8; 4]) -> SpendingCounter
Trait Implementations§
source§impl Arbitrary for SpendingCounter
impl Arbitrary for SpendingCounter
§type Parameters = ()
type Parameters = ()
The type of parameters that
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = BoxedStrategy<SpendingCounter>
type Strategy = BoxedStrategy<SpendingCounter>
The type of
Strategy
used to generate values of type Self
.source§fn arbitrary_with(
args: <SpendingCounter as Arbitrary>::Parameters
) -> <SpendingCounter as Arbitrary>::Strategy
fn arbitrary_with( args: <SpendingCounter as Arbitrary>::Parameters ) -> <SpendingCounter as Arbitrary>::Strategy
source§impl Arbitrary for SpendingCounter
impl Arbitrary for SpendingCounter
source§impl Clone for SpendingCounter
impl Clone for SpendingCounter
source§fn clone(&self) -> SpendingCounter
fn clone(&self) -> SpendingCounter
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SpendingCounter
impl Debug for SpendingCounter
source§impl From<SpendingCounter> for u32
impl From<SpendingCounter> for u32
source§fn from(v: SpendingCounter) -> u32
fn from(v: SpendingCounter) -> u32
Converts to this type from the input type.
source§impl From<u32> for SpendingCounter
impl From<u32> for SpendingCounter
source§fn from(v: u32) -> SpendingCounter
fn from(v: u32) -> SpendingCounter
Converts to this type from the input type.
source§impl PartialEq<SpendingCounter> for SpendingCounter
impl PartialEq<SpendingCounter> for SpendingCounter
source§fn eq(&self, other: &SpendingCounter) -> bool
fn eq(&self, other: &SpendingCounter) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for SpendingCounter
impl Eq for SpendingCounter
impl StructuralEq for SpendingCounter
impl StructuralPartialEq for SpendingCounter
Auto Trait Implementations§
impl RefUnwindSafe for SpendingCounter
impl Send for SpendingCounter
impl Sync for SpendingCounter
impl Unpin for SpendingCounter
impl UnwindSafe for SpendingCounter
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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request