Skip to content

Commit

Permalink
fix: remove unnecessary decode
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanlakhani committed Nov 16, 2023
1 parent cca7581 commit 51ff595
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
39 changes: 18 additions & 21 deletions homestar-runtime/tests/fixtures/test-workflow-jco.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
{
"name": "componentize",
"workflow": {
"tasks": [
{
"cause": null,
"meta": {
"memory": 4294967296,
"time": 100000
},
"prf": [],
"run": {
"input": {
"args": ["hello", 10],
"func": "sum"
},
"nnc": "",
"op": "wasm/run",
"rsc": "ipfs://"
}
"tasks": [
{
"cause": null,
"meta": {
"memory": 4294967296,
"time": 100000
},
"prf": [],
"run": {
"input": {
"args": ["hello", 10],
"func": "sum"
},
"nnc": "",
"op": "wasm/run",
"rsc": "ipfs://bafybeibawnb3pytqmky4ph37hj7y7qosqcneofjextqq55zhxfniiletfu"
}
]
}
}
]
}
11 changes: 1 addition & 10 deletions homestar-wasm/src/wasmtime/ipld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ use crate::error::{InterpreterError, TagsError};
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use itertools::{FoldWhile::Done, Itertools};
use libipld::{
cid::{
self,
multibase::{self, Base},
Cid,
},
cid::{self, multibase::Base, Cid},
Ipld,
};
use rust_decimal::{
Expand Down Expand Up @@ -345,9 +341,6 @@ impl TryFrom<RuntimeVal> for Ipld {
type Error = InterpreterError;

fn try_from(val: RuntimeVal) -> Result<Self, Self::Error> {
fn base_64_bytes(s: &str) -> Result<Vec<u8>, multibase::Error> {
Base::Base64.decode(s)
}
fn cid(s: &str) -> Result<Cid, cid::Error> {
Cid::try_from(s)
}
Expand All @@ -360,8 +353,6 @@ impl TryFrom<RuntimeVal> for Ipld {
s => {
if let Ok(cid) = cid(&s) {
Ipld::Link(cid)
} else if let Ok(decoded) = base_64_bytes(&s) {
Ipld::Bytes(decoded)
} else {
Ipld::String(s)
}
Expand Down

0 comments on commit 51ff595

Please sign in to comment.