Skip to content

Commit

Permalink
rpc: disable BigTable with header (#226)
Browse files Browse the repository at this point in the history
* rpc: disable BigTable with header

* use is_some_and instead map+unwrap_or

Co-authored-by: Tyera <[email protected]>

---------

Co-authored-by: Tyera <[email protected]>
  • Loading branch information
fanatid and CriesofCarrots authored Mar 13, 2024
1 parent 151675b commit 7c007ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ pub struct JsonRpcRequestProcessor {
}
impl Metadata for JsonRpcRequestProcessor {}

impl JsonRpcRequestProcessor {
pub fn clone_without_bigtable(&self) -> JsonRpcRequestProcessor {
Self {
bigtable_ledger_storage: None, // Disable BigTable
..self.clone()
}
}
}

impl JsonRpcRequestProcessor {
fn get_bank_with_config(&self, config: RpcContextConfig) -> Result<Arc<Bank>> {
let RpcContextConfig {
Expand Down
9 changes: 8 additions & 1 deletion rpc/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,14 @@ impl JsonRpcService {
);
let server = ServerBuilder::with_meta_extractor(
io,
move |_req: &hyper::Request<hyper::Body>| request_processor.clone(),
move |req: &hyper::Request<hyper::Body>| {
let xbigtable = req.headers().get("x-bigtable");
if xbigtable.is_some_and(|v| v == "disabled") {
request_processor.clone_without_bigtable()
} else {
request_processor.clone()
}
},
)
.event_loop_executor(runtime.handle().clone())
.threads(1)
Expand Down

0 comments on commit 7c007ea

Please sign in to comment.