Skip to content

Commit 004f8e6

Browse files
committed
graph: Fix converting bytes values to Option<H256>
The other option would be to use `H256::from_slice` but that panics if the slice length isn't 32 bytes. It seems better to catch invalid hashes rather than crashing the entire node.
1 parent 741507e commit 004f8e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

graph/src/data/store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl TryFrom<Value> for Option<H256> {
396396
match value {
397397
Value::Bytes(bytes) => {
398398
let hex = format!("{}", bytes);
399-
Ok(Some(H256::from_str(hex.as_str())?))
399+
Ok(Some(H256::from_str(hex.as_str().trim_start_matches("0x"))?))
400400
}
401401
Value::String(s) => Ok(Some(H256::from_str(s.as_str())?)),
402402
Value::Null => Ok(None),

0 commit comments

Comments
 (0)