forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check slot cleaned up for RPC blockstore/slot queries (solana-labs#9982)
automerge
- Loading branch information
1 parent
6660e93
commit 965204b
Showing
3 changed files
with
87 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use jsonrpc_core::{Error, ErrorCode}; | ||
use solana_sdk::clock::Slot; | ||
|
||
const JSON_RPC_SERVER_ERROR_0: i64 = -32000; | ||
const JSON_RPC_SERVER_ERROR_1: i64 = -32001; | ||
|
||
pub enum RpcCustomError { | ||
NonexistentClusterRoot { | ||
cluster_root: Slot, | ||
node_root: Slot, | ||
}, | ||
BlockCleanedUp { | ||
slot: Slot, | ||
first_available_block: Slot, | ||
}, | ||
} | ||
|
||
impl From<RpcCustomError> for Error { | ||
fn from(e: RpcCustomError) -> Self { | ||
match e { | ||
RpcCustomError::NonexistentClusterRoot { | ||
cluster_root, | ||
node_root, | ||
} => Self { | ||
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_0), | ||
message: format!( | ||
"Cluster largest_confirmed_root {} does not exist on node. Node root: {}", | ||
cluster_root, node_root, | ||
), | ||
data: None, | ||
}, | ||
RpcCustomError::BlockCleanedUp { | ||
slot, | ||
first_available_block, | ||
} => Self { | ||
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_1), | ||
message: format!( | ||
"Block {} cleaned up, does not exist on node. First available block: {}", | ||
slot, first_available_block, | ||
), | ||
data: None, | ||
}, | ||
} | ||
} | ||
} |