Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexed snapshot. Expose primary methods #275

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion packages/storage-plus/src/indexed_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ where
I: IndexList<T>,
{
pk_namespace: &'a [u8],
pub primary: SnapshotMap<'a, K, T>,
primary: SnapshotMap<'a, K, T>,
/// This is meant to be read directly to get the proper types, like:
/// map.idx.owner.items(...)
pub idx: I,
Expand All @@ -43,6 +43,34 @@ where
idx: indexes,
}
}

pub fn add_checkpoint(&self, store: &mut dyn Storage, height: u64) -> StdResult<()> {
self.primary.add_checkpoint(store, height)
}

pub fn remove_checkpoint(&self, store: &mut dyn Storage, height: u64) -> StdResult<()> {
self.primary.remove_checkpoint(store, height)
}
}

impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I>
where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a>,
I: IndexList<T>,
{
pub fn may_load_at_height(
&self,
store: &dyn Storage,
k: K,
height: u64,
) -> StdResult<Option<T>> {
self.primary.may_load_at_height(store, k, height)
}

pub fn assert_checkpointed(&self, store: &dyn Storage, height: u64) -> StdResult<()> {
self.primary.assert_checkpointed(store, height)
}
}

impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I>
Expand Down