From 6c09985d577cf4dff2b4894f8c50a1314c7cc8ec Mon Sep 17 00:00:00 2001 From: Sabaun Taraki Date: Tue, 27 Aug 2024 13:19:20 +0300 Subject: [PATCH] Clean-ups --- common/src/auxiliary/waitlist.rs | 2 +- gtest/src/blocks.rs | 16 ++++++++++++++-- gtest/src/gas_tree.rs | 2 +- gtest/src/mailbox/manager.rs | 17 +++-------------- gtest/src/task_pool.rs | 2 +- gtest/src/waitlist.rs | 17 +++-------------- 6 files changed, 23 insertions(+), 33 deletions(-) diff --git a/common/src/auxiliary/waitlist.rs b/common/src/auxiliary/waitlist.rs index 4bbe0cd04cf..81c746d11fd 100644 --- a/common/src/auxiliary/waitlist.rs +++ b/common/src/auxiliary/waitlist.rs @@ -40,7 +40,7 @@ pub type AuxiliaryWaitlist = WaitlistImpl< pub type WaitlistedMessage = StoredDispatch; std::thread_local! { - // Definition of the mailbox (`StorageDoubleMap`) global storage, accessed by the `Mailbox` trait implementor. + // Definition of the waitlist (`StorageDoubleMap`) global storage, accessed by the `Waitlist` trait implementor. pub(crate) static WAITLIST_STORAGE: RefCell)>> = const { RefCell::new(DoubleBTreeMap::new()) }; } diff --git a/gtest/src/blocks.rs b/gtest/src/blocks.rs index 1e4b593e792..dce699bec87 100644 --- a/gtest/src/blocks.rs +++ b/gtest/src/blocks.rs @@ -18,15 +18,15 @@ //! Block timestamp and height management. +use crate::BLOCK_DURATION_IN_MSECS; use core_processor::configs::BlockInfo; +use gear_common::{auxiliary::BlockNumber, storage::GetCallback}; use std::{ cell::RefCell, rc::Rc, time::{SystemTime, UNIX_EPOCH}, }; -use crate::BLOCK_DURATION_IN_MSECS; - type BlockInfoStorageInner = Rc>>; thread_local! { @@ -115,6 +115,18 @@ fn now() -> u64 { .as_millis() as u64 } +/// Block number getter. +/// +/// Used to get block number for auxiliary complex storage managers, +/// like auxiliary maibox, waitlist and etc. +pub(crate) struct GetBlockNumberImpl; + +impl GetCallback for GetBlockNumberImpl { + fn call() -> BlockNumber { + BlocksManager::new().get().height + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/gtest/src/gas_tree.rs b/gtest/src/gas_tree.rs index a362170424c..422ba87f4d1 100644 --- a/gtest/src/gas_tree.rs +++ b/gtest/src/gas_tree.rs @@ -36,7 +36,7 @@ pub type OriginNodeDataOf = ( type GasTree = ::GasTree; /// Gas tree manager which operates under the hood over -/// [`gear_common::AuxiliaryGasProvider`]. +/// [`gear_common::auxiliary::gas_provider::AuxiliaryGasProvider`]. /// /// Manager is needed mainly to adapt arguments of the gas tree methods to the /// crate. diff --git a/gtest/src/mailbox/manager.rs b/gtest/src/mailbox/manager.rs index 32582adf4d9..b0791569fbe 100644 --- a/gtest/src/mailbox/manager.rs +++ b/gtest/src/mailbox/manager.rs @@ -18,15 +18,15 @@ //! Mailbox manager. -use crate::blocks::BlocksManager; +use crate::blocks::GetBlockNumberImpl; use gear_common::{ auxiliary::{mailbox::*, BlockNumber}, - storage::{GetCallback, Interval, IterableByKeyMap, Mailbox, MailboxCallbacks}, + storage::{Interval, IterableByKeyMap, Mailbox, MailboxCallbacks}, }; use gear_core::ids::{MessageId, ProgramId}; /// Mailbox manager which operates under the hood over -/// [`gear_common::AuxiliaryMailbox`]. +/// [`gear_common::auxiliary::mailbox::AuxiliaryMailbox`]. #[derive(Debug, Default)] pub(crate) struct MailboxManager; @@ -80,14 +80,3 @@ impl MailboxCallbacks for MailboxCallbacksImpl { type OnInsert = (); type OnRemove = (); } - -/// Block number getter. -/// -/// Used to get block number to insert message into mailbox. -pub(crate) struct GetBlockNumberImpl; - -impl GetCallback for GetBlockNumberImpl { - fn call() -> BlockNumber { - BlocksManager::new().get().height - } -} diff --git a/gtest/src/task_pool.rs b/gtest/src/task_pool.rs index f61cb6cd6d7..edf51c89405 100644 --- a/gtest/src/task_pool.rs +++ b/gtest/src/task_pool.rs @@ -29,7 +29,7 @@ use gear_common::{ }; /// Task pool manager which operates under the hood over -/// [`gear_common::AuxiliaryTaskpool`]. +/// [`gear_common::auxiliary::task_pool::AuxiliaryTaskpool`]. /// /// Manager is needed mainly to adapt arguments of the task pool methods to the /// crate. diff --git a/gtest/src/waitlist.rs b/gtest/src/waitlist.rs index 1d5026adcd7..3145ea064d3 100644 --- a/gtest/src/waitlist.rs +++ b/gtest/src/waitlist.rs @@ -20,15 +20,15 @@ #![allow(unused)] -use crate::blocks::BlocksManager; +use crate::blocks::GetBlockNumberImpl; use gear_common::{ auxiliary::{waitlist::*, BlockNumber}, - storage::{GetCallback, Interval, IterableByKeyMap, Waitlist, WaitlistCallbacks}, + storage::{Interval, IterableByKeyMap, Waitlist, WaitlistCallbacks}, }; use gear_core::ids::{MessageId, ProgramId}; /// Waitlist manager which operates under the hood over -/// [`gear_common::AuxiliaryWaitlist`]. +/// [`gear_common::auxiliary::waitlist::AuxiliaryWaitlist`]. #[derive(Debug, Default)] pub(crate) struct WaitlistManager; @@ -79,14 +79,3 @@ impl WaitlistCallbacks for WaitlistCallbacksImpl { type OnInsert = (); type OnRemove = (); } - -/// Block number getter. -/// -/// Used to get block number to insert message into mailbox. -pub(crate) struct GetBlockNumberImpl; - -impl GetCallback for GetBlockNumberImpl { - fn call() -> BlockNumber { - BlocksManager::new().get().height - } -}