Skip to content

Commit

Permalink
sync from external: fix source and distinguish errors
Browse files Browse the repository at this point in the history
  • Loading branch information
saketh-are committed Nov 21, 2024
1 parent 955d846 commit be5637b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions chain/client/src/sync/state/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ impl StateSyncDownloadSourceExternal {
Err(near_chain::Error::Other("Timeout".to_owned()))
}
_ = cancellation.cancelled() => {
increment_download_count(shard_id, typ, "external", "error");
increment_download_count(shard_id, typ, "external", "cancelled");
Err(near_chain::Error::Other("Cancelled".to_owned()))
}
result = fut => {
result.map_err(|e| {
increment_download_count(shard_id, typ, "network", "error");
increment_download_count(shard_id, typ, "external", "download_error");
tracing::debug!(target: "sync", "Failed to download with error {}", e);
near_chain::Error::Other(format!("Failed to download: {}", e))
})
}
Expand Down Expand Up @@ -94,7 +95,7 @@ impl StateSyncDownloadSource for StateSyncDownloadSourceExternal {
)
.await?;
let header = ShardStateSyncResponseHeader::try_from_slice(&data).map_err(|e| {
increment_download_count(shard_id, "header", "external", "error");
increment_download_count(shard_id, "header", "external", "parse_error");
near_chain::Error::Other(format!("Failed to parse header: {}", e))
})?;

Expand Down

0 comments on commit be5637b

Please sign in to comment.