encode base64 snapshot response
This commit is contained in:
parent
e54af6aa9d
commit
88a32a4ac1
|
@ -2968,6 +2968,7 @@ version = "0.1.5"
|
|||
dependencies = [
|
||||
"agave-geyser-plugin-interface",
|
||||
"anyhow",
|
||||
"base64 0.21.7",
|
||||
"cargo-lock",
|
||||
"clap",
|
||||
"git-version",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"libpath": "target/release/libquic_geyser_plugin.so",
|
||||
"libpath": "target/debug/libquic_geyser_plugin.so",
|
||||
"quic_plugin": {
|
||||
"address": "0.0.0.0:10800",
|
||||
"compression_parameters": {
|
||||
|
@ -7,5 +7,8 @@
|
|||
"Lz4Fast": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
"rpc_server" : {
|
||||
"enable" : true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ quic-geyser-snapshot = { workspace = true }
|
|||
lite-account-manager-common = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
tokio = {workspace = true}
|
||||
base64 = {workspace = true}
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = { workspace = true }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
use base64::Engine;
|
||||
use itertools::Itertools;
|
||||
use jsonrpsee::server::ServerBuilder;
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
|
@ -26,7 +27,7 @@ pub trait PluginRpc {
|
|||
) -> RpcResult<OptionalContext<Vec<RpcKeyedAccount>>>;
|
||||
|
||||
#[method(name = "getSnapshot")]
|
||||
async fn get_snapshot(&self, program_id_str: String) -> RpcResult<Vec<u8>>;
|
||||
async fn get_snapshot(&self, program_id_str: String) -> RpcResult<String>;
|
||||
}
|
||||
|
||||
pub struct RpcServerImpl {
|
||||
|
@ -53,8 +54,8 @@ impl RpcServerImpl {
|
|||
let http_server_handle = ServerBuilder::default()
|
||||
.set_middleware(middleware)
|
||||
.max_connections(10)
|
||||
.max_request_body_size(16 * 1024 * 1024) // 16 MB
|
||||
.max_response_body_size(64 * 1024 * 1024 * 1024) // 64 GB
|
||||
.max_request_body_size(1024 * 1024) // 16 MB
|
||||
.max_response_body_size(1024 * 1024) // 512 MBs
|
||||
.http_only()
|
||||
.build(http_addr.clone())
|
||||
.await?
|
||||
|
@ -155,7 +156,7 @@ impl PluginRpcServer for RpcServerImpl {
|
|||
}
|
||||
}
|
||||
|
||||
async fn get_snapshot(&self, program_id_str: String) -> RpcResult<Vec<u8>> {
|
||||
async fn get_snapshot(&self, program_id_str: String) -> RpcResult<String> {
|
||||
let program_id = Pubkey::from_str(program_id_str.as_str())
|
||||
.map_err(|_| jsonrpsee::types::error::ErrorCode::InvalidParams)?;
|
||||
let res = self
|
||||
|
@ -163,7 +164,7 @@ impl PluginRpcServer for RpcServerImpl {
|
|||
.create_snapshot(program_id)
|
||||
.await
|
||||
.map_err(|_| jsonrpsee::types::error::ErrorCode::InternalError)?;
|
||||
Ok(res)
|
||||
Ok(base64::engine::general_purpose::STANDARD.encode(res))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue