Skip to content

Commit

Permalink
Fix merge issues
Browse files Browse the repository at this point in the history
Signed-off-by: Filippo Costa <filippo@sovlabs.io>
  • Loading branch information
neysofu committed Aug 23, 2023
1 parent cd40f13 commit 102aaef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
15 changes: 4 additions & 11 deletions module-system/sov-state/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,9 @@ impl<K, V> StateMap<K, V> {
}
}

impl<K, V, C> StateMap<K, V, C>
where
C: StateCodec<K, V>,
{
/// Creates a new [`StateMap`] with the given prefix and codec.
///
/// Note that `codec` must implement [`StateCodec`]. You can use
/// [`PairOfCodecs`](crate::codec::PairOfCodecs) if you wish to decouple key
/// and value codecs.
pub fn with_codec(prefix: Prefix, codec: C) -> Self {
impl<K, V, VC> StateMap<K, V, VC> {
/// Creates a new [`StateMap`] with the given prefix and [`StateValueCodec`].
pub fn with_codec(prefix: Prefix, codec: VC) -> Self {
Self {
_phantom: (PhantomData, PhantomData),
value_codec: codec,
Expand Down Expand Up @@ -124,7 +117,7 @@ where

/// Returns the value corresponding to the key or [`StateMapError`] if key is absent in
/// the map.
pub fn get_or_err<S: Storage>(
pub fn get_or_err<Q, S: Storage>(
&self,
key: &Q,
working_set: &mut WorkingSet<S>,
Expand Down
9 changes: 3 additions & 6 deletions module-system/sov-state/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ use std::marker::PhantomData;

use thiserror::Error;

use crate::codec::{BorshCodec, PairOfCodecs, StateValueCodec};
use crate::codec::{BorshCodec, StateValueCodec};
use crate::{Prefix, StateMap, StateValue, Storage, WorkingSet};

type InternalCodec<C> = PairOfCodecs<BorshCodec, C>;

#[derive(Debug, Clone)]
pub struct StateVec<V, VC = BorshCodec>
where
Expand All @@ -16,7 +14,7 @@ where
_phantom: PhantomData<V>,
prefix: Prefix,
len_value: StateValue<usize>,
elems: StateMap<usize, V, InternalCodec<VC>>,
elems: StateMap<usize, V, VC>,
}

/// Error type for `StateVec` get method.
Expand Down Expand Up @@ -50,8 +48,7 @@ where
// details of `StateValue` and `StateMap` as they both have the right to
// reserve the whole key space for themselves.
let len_value = StateValue::<usize>::new(prefix.extended(b"l"));
let elems =
StateMap::with_codec(prefix.extended(b"e"), InternalCodec::new(BorshCodec, codec));
let elems = StateMap::with_codec(prefix.extended(b"e"), codec);
Self {
_phantom: PhantomData,
prefix,
Expand Down

0 comments on commit 102aaef

Please sign in to comment.