use {
std::{env, fs, path::Path},
tonic_prost_build::manual::{Builder, Method, Service},
};
fn main() -> anyhow::Result<()> {
std::env::set_var("PROTOC", protobuf_src::protoc());
tonic_prost_build::configure().compile_protos(&["proto/geyser.proto"], &["proto"])?;
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not found");
let out_dir_path = Path::new(&out_dir).join("no-tonic");
fs::create_dir_all(&out_dir_path).expect("failed to create out no-tonic directory");
tonic_prost_build::configure()
.build_client(false)
.build_server(false)
.out_dir(out_dir_path)
.compile_protos(&["proto/geyser.proto"], &["proto"])?;
let geyser_service = Service::builder()
.name("Geyser")
.package("geyser")
.method(
Method::builder()
.name("subscribe")
.route_name("Subscribe")
.input_type("crate::geyser::SubscribeRequest")
.output_type("crate::plugin::filter::message::FilteredUpdate")
.codec_path("tonic_prost::ProstCodec")
.client_streaming()
.server_streaming()
.build(),
)
.method(
Method::builder()
.name("subscribe_raw")
.route_name("SubscribeRaw")
.input_type("crate::geyser::SubscribeRequest")
.output_type("crate::plugin::filter::message::FilteredUpdate")
.codec_path("tonic_prost::ProstCodec")
.client_streaming()
.server_streaming()
.build(),
)
.method(
Method::builder()
.name("subscribe_batch")
.route_name("SubscribeBatch")
.input_type("crate::geyser::SubscribeRequest")
.output_type("crate::plugin::filter::message::FilteredUpdateBatch")
.codec_path("tonic_prost::ProstCodec")
.client_streaming()
.server_streaming()
.build(),
)
.method(
Method::builder()
.name("subscribe_first_available_slot")
.route_name("SubscribeReplayInfo")
.input_type("crate::geyser::SubscribeReplayInfoRequest")
.output_type("crate::geyser::SubscribeReplayInfoResponse")
.codec_path("tonic_prost::ProstCodec")
.build(),
)
.method(
Method::builder()
.name("ping")
.route_name("Ping")
.input_type("crate::geyser::PingRequest")
.output_type("crate::geyser::PongResponse")
.codec_path("tonic_prost::ProstCodec")
.build(),
)
.method(
Method::builder()
.name("get_latest_blockhash")
.route_name("GetLatestBlockhash")
.input_type("crate::geyser::GetLatestBlockhashRequest")
.output_type("crate::geyser::GetLatestBlockhashResponse")
.codec_path("tonic_prost::ProstCodec")
.build(),
)
.method(
Method::builder()
.name("get_block_height")
.route_name("GetBlockHeight")
.input_type("crate::geyser::GetBlockHeightRequest")
.output_type("crate::geyser::GetBlockHeightResponse")
.codec_path("tonic_prost::ProstCodec")
.build(),
)
.method(
Method::builder()
.name("get_slot")
.route_name("GetSlot")
.input_type("crate::geyser::GetSlotRequest")
.output_type("crate::geyser::GetSlotResponse")
.codec_path("tonic_prost::ProstCodec")
.build(),
)
.method(
Method::builder()
.name("is_blockhash_valid")
.route_name("IsBlockhashValid")
.input_type("crate::geyser::IsBlockhashValidRequest")
.output_type("crate::geyser::IsBlockhashValidResponse")
.codec_path("tonic_prost::ProstCodec")
.build(),
)
.method(
Method::builder()
.name("get_version")
.route_name("GetVersion")
.input_type("crate::geyser::GetVersionRequest")
.output_type("crate::geyser::GetVersionResponse")
.codec_path("tonic_prost::ProstCodec")
.build(),
)
.build();
Builder::new()
.build_client(false)
.compile(&[geyser_service]);
Ok(())
}