pub struct TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>(/* private fields */);Trait Implementations§
Source§impl<TotalValue, Balance, Funds, InternalError, Error, ExternalId, NodeId, StorageMap> LockableTree for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
Balance: BalanceTrait,
Funds: Clone,
TotalValue: ValueStorage<Value = Balance>,
InternalError: Error,
Error: From<InternalError>,
ExternalId: Clone,
NodeId: Copy,
StorageMap: MapStorage<Key = NodeId, Value = GasNode<ExternalId, NodeId, Balance, Funds>>,
impl<TotalValue, Balance, Funds, InternalError, Error, ExternalId, NodeId, StorageMap> LockableTree for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
Balance: BalanceTrait,
Funds: Clone,
TotalValue: ValueStorage<Value = Balance>,
InternalError: Error,
Error: From<InternalError>,
ExternalId: Clone,
NodeId: Copy,
StorageMap: MapStorage<Key = NodeId, Value = GasNode<ExternalId, NodeId, Balance, Funds>>,
Source§fn lock(
key: impl Into<Self::NodeId>,
id: LockId,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn lock( key: impl Into<Self::NodeId>, id: LockId, amount: Self::Balance, ) -> Result<(), Self::Error>
Source§fn unlock(
key: impl Into<Self::NodeId>,
id: LockId,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn unlock( key: impl Into<Self::NodeId>, id: LockId, amount: Self::Balance, ) -> Result<(), Self::Error>
Source§impl<TotalValue, Balance, Funds, InternalError, Error, ExternalId, NodeId, StorageMap> ReservableTree for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
Balance: BalanceTrait,
Funds: Clone,
TotalValue: ValueStorage<Value = Balance>,
InternalError: Error,
Error: From<InternalError>,
ExternalId: Clone,
NodeId: Copy,
StorageMap: MapStorage<Key = NodeId, Value = GasNode<ExternalId, NodeId, Balance, Funds>>,
impl<TotalValue, Balance, Funds, InternalError, Error, ExternalId, NodeId, StorageMap> ReservableTree for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
Balance: BalanceTrait,
Funds: Clone,
TotalValue: ValueStorage<Value = Balance>,
InternalError: Error,
Error: From<InternalError>,
ExternalId: Clone,
NodeId: Copy,
StorageMap: MapStorage<Key = NodeId, Value = GasNode<ExternalId, NodeId, Balance, Funds>>,
Source§fn reserve(
key: impl Into<Self::NodeId>,
new_key: impl Into<Self::NodeId>,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn reserve( key: impl Into<Self::NodeId>, new_key: impl Into<Self::NodeId>, amount: Self::Balance, ) -> Result<(), Self::Error>
Source§fn system_reserve(
key: impl Into<Self::NodeId>,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn system_reserve( key: impl Into<Self::NodeId>, amount: Self::Balance, ) -> Result<(), Self::Error>
Source§impl<TotalValue, Balance, Funds, InternalError, Error, ExternalId, NodeId, StorageMap> Tree for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
Balance: BalanceTrait,
Funds: Clone,
TotalValue: ValueStorage<Value = Balance>,
InternalError: Error,
Error: From<InternalError>,
ExternalId: Clone,
NodeId: Copy,
StorageMap: MapStorage<Key = NodeId, Value = GasNode<ExternalId, NodeId, Balance, Funds>>,
impl<TotalValue, Balance, Funds, InternalError, Error, ExternalId, NodeId, StorageMap> Tree for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
Balance: BalanceTrait,
Funds: Clone,
TotalValue: ValueStorage<Value = Balance>,
InternalError: Error,
Error: From<InternalError>,
ExternalId: Clone,
NodeId: Copy,
StorageMap: MapStorage<Key = NodeId, Value = GasNode<ExternalId, NodeId, Balance, Funds>>,
Source§fn consume(key: impl Into<Self::NodeId>) -> ConsumeResultOf<Self>
fn consume(key: impl Into<Self::NodeId>) -> ConsumeResultOf<Self>
Marks a node with key as consumed, if possible, and tries to return
it’s value and delete it. The function performs same procedure with all
the nodes on the path from it to the root, if possible.
Marking a node as consumed is possible only for GasNode::External
and GasNode::SpecifiedLocal nodes. That is because these nodes can
be not deleted after the function call, because of, for instance,
having children refs. Such nodes as GasNode::UnspecifiedLocal
and GasNode::ReservedLocal are removed when the function is
called, so there is no need for marking them as consumed.
When consuming the node, it’s value is mutated by calling catch_value,
which tries to either return or move value upstream if possible.
Read the catch_value function’s documentation for details.
To delete node, here should be two requirements:
Self::consumewas called on the node.- The node has no children, i.e. spec/unspec refs.
So if it’s impossible to delete a node, then it’s impossible to delete its parent in the current call. Also if it’s possible to delete a node, then it doesn’t necessarily mean that its parent will be deleted. An example here could be the case, when during async execution original message went to wait list, so wasn’t consumed but the one generated during the execution of the original message went to message queue and was successfully executed.
Source§fn spend(
key: impl Into<Self::NodeId>,
amount: Self::Balance,
) -> Result<Self::NegativeImbalance, Self::Error>
fn spend( key: impl Into<Self::NodeId>, amount: Self::Balance, ) -> Result<Self::NegativeImbalance, Self::Error>
Spends amount of gas from the ancestor of node with key id.
Calling the function is possible even if an ancestor is consumed.
§Note:
Node is considered as an ancestor of itself.
Source§type ExternalOrigin = ExternalId
type ExternalOrigin = ExternalId
Source§type PositiveImbalance = PositiveImbalance<Balance>
type PositiveImbalance = PositiveImbalance<Balance>
PositiveImbalance indicates that some value has been added
to circulation , i.e. total supply has increased.Source§type NegativeImbalance = NegativeImbalance<Balance>
type NegativeImbalance = NegativeImbalance<Balance>
NegativeImbalance indicates that some value has been removed
from circulation, i.e. total supply has decreased.type InternalError = InternalError
Source§fn total_supply() -> Self::Balance
fn total_supply() -> Self::Balance
Source§fn create(
origin: Self::ExternalOrigin,
multiplier: GasMultiplier<Self::Funds, Self::Balance>,
key: impl Into<Self::NodeId>,
amount: Self::Balance,
) -> Result<Self::PositiveImbalance, Self::Error>
fn create( origin: Self::ExternalOrigin, multiplier: GasMultiplier<Self::Funds, Self::Balance>, key: impl Into<Self::NodeId>, amount: Self::Balance, ) -> Result<Self::PositiveImbalance, Self::Error>
amount of it and attributing it to the origin. Read moreSource§fn get_origin_node(
key: impl Into<Self::NodeId>,
) -> Result<OriginNodeDataOf<Self>, Self::Error>
fn get_origin_node( key: impl Into<Self::NodeId>, ) -> Result<OriginNodeDataOf<Self>, Self::Error>
Source§fn get_limit_node(
key: impl Into<Self::NodeId>,
) -> Result<(Self::Balance, Self::NodeId), Self::Error>
fn get_limit_node( key: impl Into<Self::NodeId>, ) -> Result<(Self::Balance, Self::NodeId), Self::Error>
Source§fn get_limit_node_consumed(
key: impl Into<Self::NodeId>,
) -> Result<(Self::Balance, Self::NodeId), Self::Error>
fn get_limit_node_consumed( key: impl Into<Self::NodeId>, ) -> Result<(Self::Balance, Self::NodeId), Self::Error>
Source§fn split_with_value(
key: impl Into<Self::NodeId>,
new_key: impl Into<Self::NodeId>,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn split_with_value( key: impl Into<Self::NodeId>, new_key: impl Into<Self::NodeId>, amount: Self::Balance, ) -> Result<(), Self::Error>
Source§fn split(
key: impl Into<Self::NodeId>,
new_key: impl Into<Self::NodeId>,
) -> Result<(), Self::Error>
fn split( key: impl Into<Self::NodeId>, new_key: impl Into<Self::NodeId>, ) -> Result<(), Self::Error>
Source§fn cut(
key: impl Into<Self::NodeId>,
new_key: impl Into<Self::NodeId>,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn cut( key: impl Into<Self::NodeId>, new_key: impl Into<Self::NodeId>, amount: Self::Balance, ) -> Result<(), Self::Error>
Source§fn create_deposit(
key: impl Into<Self::NodeId>,
new_key: impl Into<Self::NodeId>,
amount: Self::Balance,
) -> Result<(), Self::Error>
fn create_deposit( key: impl Into<Self::NodeId>, new_key: impl Into<Self::NodeId>, amount: Self::Balance, ) -> Result<(), Self::Error>
Source§fn exists_and_deposit(key: impl Into<Self::NodeId>) -> bool
fn exists_and_deposit(key: impl Into<Self::NodeId>) -> bool
Source§fn get_external(
key: impl Into<Self::NodeId>,
) -> Result<Self::ExternalOrigin, Self::Error>
fn get_external( key: impl Into<Self::NodeId>, ) -> Result<Self::ExternalOrigin, Self::Error>
Source§fn get_funds_multiplier(
key: impl Into<Self::NodeId>,
) -> Result<GasMultiplier<Self::Funds, Self::Balance>, Self::Error>
fn get_funds_multiplier( key: impl Into<Self::NodeId>, ) -> Result<GasMultiplier<Self::Funds, Self::Balance>, Self::Error>
Source§fn get_origin_key(
key: impl Into<Self::NodeId>,
) -> Result<Self::NodeId, Self::Error>
fn get_origin_key( key: impl Into<Self::NodeId>, ) -> Result<Self::NodeId, Self::Error>
Auto Trait Implementations§
impl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap> Freeze for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>
impl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap> RefUnwindSafe for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
TotalValue: RefUnwindSafe,
InternalError: RefUnwindSafe,
Error: RefUnwindSafe,
ExternalId: RefUnwindSafe,
NodeId: RefUnwindSafe,
StorageMap: RefUnwindSafe,
impl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap> Send for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>
impl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap> Sync for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>
impl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap> Unpin for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>
impl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap> UnwindSafe for TreeImpl<TotalValue, InternalError, Error, ExternalId, NodeId, StorageMap>where
TotalValue: UnwindSafe,
InternalError: UnwindSafe,
Error: UnwindSafe,
ExternalId: UnwindSafe,
NodeId: UnwindSafe,
StorageMap: UnwindSafe,
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> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.