-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
bugSomething isn't workingSomething isn't working
Description
There are a few Result::ok()
calls in the source code - a few of them are redundant, and a few of them are used wrongly.
- We convert
Option
toResult
and then toOption
. This is redundant as we can simply use the firstOption
.
basecoin-rs/crates/app/src/modules/ibc/router.rs
Lines 64 to 72 in dc3b43a
fn lookup_module(&self, port_id: &PortId) -> Option<ModuleId> { | |
self.port_to_module_map | |
.get(port_id) | |
.ok_or(RouterError::UnknownPort { | |
port_id: port_id.clone(), | |
}) | |
.cloned() | |
.ok() | |
} |
- We ignore the fact path serialization has failed.
basecoin-rs/crates/app/src/abci/v0_38/tendermint.rs
Lines 75 to 82 in dc3b43a
let path: Option<Path> = request.path.try_into().ok(); | |
let modules = self.modules.read_access(); | |
let height = Height::from(request.height as u64); | |
for IdentifiedModule { id, module } in modules.iter() { | |
match module.query(&request.data, path.as_ref(), height, request.prove) { |
- We ignore a codec encode/decode that has failed in concrete
Codec
implementations. For example, withJsonCodec
,
basecoin-rs/crates/store/src/utils/codec.rs
Lines 26 to 33 in dc3b43a
fn encode(d: &Self::Value) -> Option<Self::Encoded> { | |
serde_json::to_string(d).ok() | |
} | |
fn decode(bytes: &[u8]) -> Option<Self::Value> { | |
let json_string = String::from_utf8(bytes.to_vec()).ok()?; | |
serde_json::from_str(&json_string).ok() | |
} |
The Codec
trait should have an associated type Error
which lets us return a Result
with the failure type.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working