Skip to content

Commit

Permalink
Adapt encoding for blockstore changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Mar 3, 2023
1 parent c333c02 commit f4f0f8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 2 additions & 8 deletions ipld/encoding/src/cbor_store.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021-2023 Protocol Labs
// SPDX-License-Identifier: Apache-2.0, MIT
use cid::{multihash, Cid};
use fvm_ipld_blockstore::{Block, Blockstore};
use fvm_ipld_blockstore::Blockstore;
use serde::{de, ser};

use crate::DAG_CBOR;
Expand All @@ -28,13 +28,7 @@ pub trait CborStore: Blockstore + Sized {
S: ser::Serialize,
{
let bytes = crate::to_vec(obj)?;
self.put(
code,
&Block {
codec: DAG_CBOR,
data: &bytes,
},
)
self.put(code.into(), &(DAG_CBOR, bytes))
}
}

Expand Down
11 changes: 11 additions & 0 deletions ipld/encoding/src/ipld_block.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::{Debug, Formatter};

use fvm_ipld_blockstore::Block;
// Copyright 2021-2023 Protocol Labs
// SPDX-License-Identifier: Apache-2.0, MIT
use serde::de::value;
Expand Down Expand Up @@ -33,6 +34,16 @@ impl Debug for IpldBlock {
}
}

impl Block for IpldBlock {
fn codec(&self) -> u64 {
self.codec
}

fn data(&self) -> &[u8] {
&self.data
}
}

impl IpldBlock {
pub fn deserialize<'de, T>(&'de self) -> Result<T, Error>
where
Expand Down

0 comments on commit f4f0f8c

Please sign in to comment.