Skip to content

Commit

Permalink
encode ipld data using cbor-json
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Dec 19, 2023
1 parent 8012e27 commit 6aa9344
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions dwn/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ fn ipld_to_pb(ipld: Ipld) -> Ipld {
let mut links = Vec::<Ipld>::new();

let data: Vec<u8> = match ipld {
Ipld::Null => Vec::new(),
Ipld::String(str) => str.into(),
Ipld::Bytes(bytes) => bytes,
Ipld::Integer(int) => int.to_be_bytes().to_vec(),
Ipld::Bool(boolean) => {
if boolean {
vec![1]
} else {
vec![0]
}
}
Ipld::Map(map) => {
for (key, value) in map {
let mut pb_link = BTreeMap::<String, Ipld>::new();
Expand Down Expand Up @@ -83,7 +72,7 @@ fn ipld_to_pb(ipld: Ipld) -> Ipld {

Vec::new()
}
Ipld::Float(float) => float.to_be_bytes().to_vec(),
_ => DagJsonCodec.encode(&ipld).unwrap(),
};

let mut pb_node = BTreeMap::<String, Ipld>::new();
Expand Down

0 comments on commit 6aa9344

Please sign in to comment.