pub struct StorageManager {
storage: HashMap<String, AccountStorage>,
read_count: u64,
write_count: u64,
gas_costs: StorageGasCosts,
}Expand description
Storage manager for contract storage
Fields§
§storage: HashMap<String, AccountStorage>§read_count: u64§write_count: u64§gas_costs: StorageGasCostsImplementations§
§impl StorageManager
impl StorageManager
pub fn new(_config: &RuntimeConfig) -> Result<Self, RuntimeError>
pub fn new(_config: &RuntimeConfig) -> Result<Self, RuntimeError>
Create new storage manager
§impl StorageManager
impl StorageManager
§impl StorageManager
impl StorageManager
pub fn get_storage_size(&self, account: &str) -> Result<usize, RuntimeError>
pub fn get_storage_size(&self, account: &str) -> Result<usize, RuntimeError>
Get storage size for account
§impl StorageManager
impl StorageManager
pub fn commit(
&mut self,
account: &str,
) -> Result<Vec<StorageChange>, RuntimeError>
pub fn commit( &mut self, account: &str, ) -> Result<Vec<StorageChange>, RuntimeError>
Commit pending changes
pub fn rollback(&mut self, account: &str) -> Result<(), RuntimeError>
pub fn rollback(&mut self, account: &str) -> Result<(), RuntimeError>
Rollback pending changes
pub fn get_pending_changes(&self, account: &str) -> Vec<&StorageChange>
pub fn get_pending_changes(&self, account: &str) -> Vec<&StorageChange>
Get all pending changes for account
pub fn calculate_pending_gas_cost(&self, account: &str) -> u64
pub fn calculate_pending_gas_cost(&self, account: &str) -> u64
Calculate total gas cost for pending changes
§impl StorageManager
impl StorageManager
pub fn query(
&mut self,
query: StorageQuery,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>, RuntimeError>
pub fn query( &mut self, query: StorageQuery, ) -> Result<Vec<(Vec<u8>, Vec<u8>)>, RuntimeError>
Query storage with filters
pub fn get_storage_root(&self, account: &str) -> Result<String, RuntimeError>
pub fn get_storage_root(&self, account: &str) -> Result<String, RuntimeError>
Get storage root hash for account (Neo compatibility)
§impl StorageManager
impl StorageManager
pub fn read_count(&self) -> u64
pub fn read_count(&self) -> u64
Get read count
pub fn write_count(&self) -> u64
pub fn write_count(&self) -> u64
Get write count
pub fn get_statistics(&self) -> StorageStatistics
pub fn get_statistics(&self) -> StorageStatistics
Get storage statistics
pub fn clear(&mut self)
pub fn clear(&mut self)
Clear all storage (for testing)
§impl StorageManager
impl StorageManager
fn calculate_storage_gas_cost( &self, change_type: &StorageChangeType, value_size: usize, ) -> u64
fn calculate_merkle_root(&self, items: &[(&Vec<u8>, &Vec<u8>)]) -> Vec<u8> ⓘ
fn empty_root_hash(&self) -> Vec<u8> ⓘ
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StorageManager
impl RefUnwindSafe for StorageManager
impl Send for StorageManager
impl Sync for StorageManager
impl Unpin for StorageManager
impl UnwindSafe for StorageManager
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more