Skip to content

Commit

Permalink
chore: proper way to parse as CryptoHash
Browse files Browse the repository at this point in the history
  • Loading branch information
frolvanya committed Nov 6, 2024
1 parent c94b71f commit df765f9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions chain/jsonrpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use near_primitives::types::{AccountId, BlockHeight, BlockId, BlockReference};
use near_primitives::views::{QueryRequest, TxExecutionStatus};
use serde_json::{json, Value};
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::time::{sleep, timeout};
Expand Down Expand Up @@ -1374,11 +1375,13 @@ async fn handle_unknown_block(
};

if let Some(block_hash) = block_id.as_str() {
let Ok(block_hash) = CryptoHash::from_str(block_hash) else {
return HttpResponse::Ok();
};

if let Ok(block) = handler
.block(RpcBlockRequest {
block_reference: BlockReference::BlockId(BlockId::Hash(CryptoHash::hash_bytes(
block_hash.as_bytes(),
))),
block_reference: BlockReference::BlockId(BlockId::Hash(block_hash)),
})
.await
{
Expand Down

0 comments on commit df765f9

Please sign in to comment.