From 59d0e5441a232363eabdc46517744f1fb83f6181 Mon Sep 17 00:00:00 2001 From: GarmashAlex Date: Sat, 11 Jan 2025 13:05:34 +0300 Subject: [PATCH] docs: Improve MemoryTemporaryStorage documentation - Add comprehensive documentation for MemoryTemporaryStorage struct explaining its purpose and behavior - Document remove() method with clear description of its return value - Document take() method with explanation of its functionality and return behavior - Fix missing documentation for core storage operations --- base/src/mem_tmp_storage.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/base/src/mem_tmp_storage.rs b/base/src/mem_tmp_storage.rs index 6886fec9e..6168cc91e 100644 --- a/base/src/mem_tmp_storage.rs +++ b/base/src/mem_tmp_storage.rs @@ -9,7 +9,9 @@ pub type StorageMap = BTreeMap, Vec>; ////// Runtime Code ////// -/// TODO docs +/// A temporary in-memory key-value storage implementation that provides basic storage operations. +/// This storage is cleared at the beginning of each block building and is not fork-aware. +/// It can be used for storing auxiliary information that doesn't need to persist across blocks. pub struct MemoryTemporaryStorage; impl MemoryTemporaryStorage { /// Returns the value under `key` from the memory temporal storage. @@ -24,12 +26,14 @@ impl MemoryTemporaryStorage { .and_then(|raw| T::decode(&mut raw.as_slice()).ok()) } - /// TODO docs + /// Removes a value from the memory temporal storage by its key. + /// Returns true if the value was present and removed, false otherwise. pub fn remove(key: &[u8]) -> bool { hosted_mem_tmp_storage::take(key).is_some() } - /// TODO docs + /// Removes and returns the value associated with the given key from the memory temporal storage. + /// Returns None if the key doesn't exist. pub fn take(key: &[u8]) -> Option { hosted_mem_tmp_storage::take(key).and_then(|raw| T::decode(&mut raw.as_slice()).ok()) }