Skip to content

Commit

Permalink
fix scanning. (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinyuchan authored Feb 27, 2024
1 parent fc8affc commit a15dccd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
8 changes: 5 additions & 3 deletions prismer/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Subscribe {

let itv = env::var("INTERVAL")
.ok()
.unwrap_or(String::from("12"))
.unwrap_or(String::from("15"))
.parse::<u64>()?;
let interval = Duration::from_secs(itv);
info!("interval={:?}", interval);
Expand All @@ -162,7 +162,7 @@ impl Subscribe {
} else if let Ok(h) = db::load_last_height(&pool).await {
h + 1
} else {
let prism_start = std::env::var("PRISM_START").unwrap_or(String::from("1"));
let prism_start = env::var("PRISM_START").unwrap_or("4004430".to_string());
prism_start.parse::<i64>().unwrap()
};

Expand Down Expand Up @@ -192,7 +192,9 @@ impl Subscribe {
Ok(_) => {
info!("Block at {} loaded.", cursor);
}
Err(Error::NotFound) => (),
Err(Error::NotFound) => {
error!("Block {} not found.", cursor);
}
Err(e) => return Err(e),
};
tokio::time::sleep(interval).await;
Expand Down
7 changes: 6 additions & 1 deletion prismer/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ impl TendermintRPC {
let resp = self.client.get(url).send().await?;
let status = resp.status();
if !status.is_success() {
return Err(resp.text().await?.into());
let resp_text = resp.text().await?;
if resp_text.contains("less than or equal to") {
return Err(Error::NotFound);
}
return Err(resp_text.into());
}

let bytes = resp.bytes().await?;
if let Ok(r) = serde_json::from_slice::<'_, JsonRpcResponse<T>>(&bytes) {
Ok(r.result)
Expand Down
6 changes: 4 additions & 2 deletions scanner/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Subscribe {

let itv = env::var("INTERVAL")
.ok()
.unwrap_or(String::from("12"))
.unwrap_or(String::from("15"))
.parse::<u64>()?;
let interval = Duration::from_secs(itv);
info!("interval={:?}", interval);
Expand Down Expand Up @@ -210,7 +210,9 @@ impl Subscribe {
Ok(_) => {
info!("Block at {} loaded.", cursor);
}
Err(Error::NotFound) => (),
Err(Error::NotFound) => {
error!("Block {} not found.", cursor);
}
Err(e) => return Err(e),
};
tokio::time::sleep(interval).await;
Expand Down
7 changes: 6 additions & 1 deletion scanner/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ impl TendermintRPC {
let resp = self.client.get(url).send().await?;
let status = resp.status();
if !status.is_success() {
return Err(resp.text().await?.into());
let resp_text = resp.text().await?;
if resp_text.contains("less than or equal to") {
return Err(Error::NotFound);
}
return Err(resp_text.into());
}

let bytes = resp.bytes().await?;
if let Ok(r) = serde_json::from_slice::<'_, JsonRpcResponse<T>>(&bytes) {
Ok(r.result)
Expand Down

0 comments on commit a15dccd

Please sign in to comment.