Skip to content

Commit

Permalink
Fix the StorageVec type by excluding the len_cached field from it…
Browse files Browse the repository at this point in the history
…s type info (#2052)

* Fix StorageVec TypeInfo

* Changelog updated

* Used codec(skip) for len_cached

* Changelog updated
  • Loading branch information
smiasojed authored Jan 10, 2024
1 parent 4531ba6 commit 54e0177
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/paritytech/ink/pull/2052)

## Version 5.0.0-rc

Expand Down
10 changes: 1 addition & 9 deletions crates/storage/src/lazy/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub struct StorageVec<V: Packed, KeyType: StorageKey = AutoKey> {
///
/// Because of caching, never operate on this field directly!
/// Always use `fn get_len()` an `fn set_len()` instead.
#[cfg_attr(feature = "std", codec(skip))]
len_cached: CachedLen,
/// We use a [Mapping] to store all elements of the vector.
/// Each element is living in storage under `&(KeyType::KEY, index)`.
Expand All @@ -130,15 +131,6 @@ pub struct StorageVec<V: Packed, KeyType: StorageKey = AutoKey> {
#[derive(Debug)]
struct CachedLen(Cell<Option<u32>>);

#[cfg(feature = "std")]
impl scale_info::TypeInfo for CachedLen {
type Identity = Option<u32>;

fn type_info() -> scale_info::Type {
<Self::Identity as scale_info::TypeInfo>::type_info()
}
}

impl<V, KeyType> Default for StorageVec<V, KeyType>
where
V: Packed,
Expand Down

0 comments on commit 54e0177

Please sign in to comment.