pub trait LockableTree: Tree {
    // Required methods
    fn lock(
        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>;
    fn get_lock(
        key: impl Into<Self::NodeId>,
        id: LockId
    ) -> Result<Self::Balance, Self::Error>;

    // Provided method
    fn unlock_all(
        key: impl Into<Self::NodeId>,
        id: LockId
    ) -> Result<Self::Balance, Self::Error> { ... }
}

Required Methods§

source

fn lock( key: impl Into<Self::NodeId>, id: LockId, amount: Self::Balance ) -> Result<(), Self::Error>

Locking some value from underlying node balance.

If key does not identify any value or the amount exceeds what’s locked under that key, an error is returned.

This can’t create imbalance as no value is burned or created.

source

fn unlock( key: impl Into<Self::NodeId>, id: LockId, amount: Self::Balance ) -> Result<(), Self::Error>

Unlocking some value from node’s locked balance.

If key does not identify any value or the amount exceeds what’s locked under that key, an error is returned.

This can’t create imbalance as no value is burned or created.

source

fn get_lock( key: impl Into<Self::NodeId>, id: LockId ) -> Result<Self::Balance, Self::Error>

Get locked value associated with given id.

Returns errors in cases of absence associated with given key node, or if such functionality is forbidden for specific node type: for example, for GasNode::ReservedLocal.

Provided Methods§

source

fn unlock_all( key: impl Into<Self::NodeId>, id: LockId ) -> Result<Self::Balance, Self::Error>

Unlocking all value from node’s locked balance. Returns the actual amount having been unlocked (wrapped in a Result)

See unlock for details.

Object Safety§

This trait is not object safe.

Implementors§

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>>,