Skip to content

Commit

Permalink
refactor(common): move LockId to gear-core
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Jul 20, 2023
1 parent 96b0558 commit 453484e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions common/src/gas_provider/lockable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use super::{scheduler::StorageType, *};
use enum_iterator::Sequence;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Sequence)]
#[repr(u8)]
pub enum LockId {
Mailbox,
Waitlist,
Reservation,
DispatchStash,
}
pub use gear_core::gas::LockId;

/// An error indicating there is no corresponding enum variant to the one provided
#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hex = { workspace = true, features = ["alloc"] }
hashbrown.workspace = true
static_assertions.workspace = true
paste = { workspace = true }
enum-iterator.workspace = true

[dev-dependencies]
wabt.workspace = true
Expand Down
15 changes: 15 additions & 0 deletions core/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,23 @@
//! Gas module.

use crate::costs::RuntimeCosts;
use enum_iterator::Sequence;
use scale_info::scale::{Decode, Encode};

/// The id of the gas lock.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Sequence)]
#[repr(u8)]
pub enum LockId {
/// The gas lock is provided by the mailbox.
Mailbox,
/// The gas lock is provided by the waitlist.
Waitlist,
/// The gas lock is provided by reservation.
Reservation,
/// The gas lock is provided by dispatch stash.
DispatchStash,
}

/// This trait represents a token that can be used for charging `GasCounter`.
///
/// Implementing type is expected to be super lightweight hence `Copy` (`Clone` is added
Expand Down

0 comments on commit 453484e

Please sign in to comment.