Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
delete useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
KaoImin committed May 28, 2020
1 parent 9cf1a84 commit ef174fd
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions framework/src/binding/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,6 @@ pub use array::DefaultStoreArray;
pub use map::DefaultStoreMap;
pub use primitive::{DefaultStoreBool, DefaultStoreString, DefaultStoreUint64};

pub struct FixedKeys<K: FixedCodec> {
pub inner: Vec<K>,
}

impl<K: FixedCodec> rlp::Encodable for FixedKeys<K> {
fn rlp_append(&self, s: &mut rlp::RlpStream) {
let inner: Vec<Vec<u8>> = self
.inner
.iter()
.map(|k| k.encode_fixed().expect("encode should not fail").to_vec())
.collect();

s.begin_list(1).append_list::<Vec<u8>, _>(&inner);
}
}

impl<K: FixedCodec> rlp::Decodable for FixedKeys<K> {
fn decode(r: &rlp::Rlp) -> Result<Self, rlp::DecoderError> {
let inner_u8: Vec<Vec<u8>> = rlp::decode_list(r.at(0)?.as_raw());

let inner_k: Result<Vec<K>, _> = inner_u8
.into_iter()
.map(|v| <_>::decode_fixed(Bytes::from(v)))
.collect();

let inner = inner_k.map_err(|_| rlp::DecoderError::Custom("decode K from bytes fail"))?;

Ok(FixedKeys { inner })
}
}

impl<K: FixedCodec> FixedCodec for FixedKeys<K> {
fn encode_fixed(&self) -> ProtocolResult<Bytes> {
Ok(Bytes::from(rlp::encode(self)))
}

fn decode_fixed(bytes: Bytes) -> ProtocolResult<Self> {
Ok(rlp::decode(bytes.as_ref()).map_err(FixedCodecError::from)?)
}
}

pub struct FixedBuckets<K: FixedCodec + PartialEq> {
pub keys_bucket: Vec<Bucket<K>>,
pub bucket_lens: Vec<u32>,
Expand Down

0 comments on commit ef174fd

Please sign in to comment.