Skip to content

Commit

Permalink
client: add GeyserGrpcBuilder (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Apr 4, 2024
1 parent a5dc933 commit d2c4659
Show file tree
Hide file tree
Showing 19 changed files with 444 additions and 254 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ The minor version will be incremented upon a breaking change and the patch versi

### Fixes

### Features

### Breaking

## 2024-04-04

- yellowstone-grpc-client-1.15.0+solana.1.18.9
- yellowstone-grpc-geyser-1.14.0+solana.1.18.9
- yellowstone-grpc-proto-1.14.0+solana.1.18.9
- yellowstone-grpc-tools-1.0.0-rc.11+solana.1.18.9

### Fixes

- deps: update `h2` crate (`RUSTSEC-2024-0332`) ([#316](https://github.com/rpcpool/yellowstone-grpc/pull/316))

### Features
Expand All @@ -25,6 +38,8 @@ The minor version will be incremented upon a breaking change and the patch versi

### Breaking

- client: add `GeyserGrpcBuilder` ([#309](https://github.com/rpcpool/yellowstone-grpc/pull/309))

## 2024-03-20

- yellowstone-grpc-client-1.14.0+solana.1.18.7
Expand Down
67 changes: 33 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
resolver = "2"
members = [
"examples/rust", # 1.12.0+solana.1.18.7
"yellowstone-grpc-client", # 1.14.0+solana.1.18.7
"yellowstone-grpc-geyser", # 1.13.0+solana.1.18.7
"yellowstone-grpc-proto", # 1.13.0+solana.1.18.7
"yellowstone-grpc-tools", # 1.0.0-rc.10+solana.1.18.7
"examples/rust", # 1.13.0+solana.1.18.9
"yellowstone-grpc-client", # 1.15.0+solana.1.18.9
"yellowstone-grpc-geyser", # 1.14.0+solana.1.18.9
"yellowstone-grpc-proto", # 1.14.0+solana.1.18.9
"yellowstone-grpc-tools", # 1.0.0-rc.11+solana.1.18.9
]

[workspace.package]
Expand Down Expand Up @@ -51,11 +51,11 @@ serde = "1.0.145"
serde_json = "1.0.86"
serde_yaml = "0.9.25"
sha2 = "0.10.7"
solana-account-decoder = "=1.18.7"
solana-geyser-plugin-interface = "=1.18.7"
solana-logger = "=1.18.7"
solana-sdk = "=1.18.7"
solana-transaction-status = "=1.18.7"
solana-account-decoder = "=1.18.9"
solana-geyser-plugin-interface = "=1.18.9"
solana-logger = "=1.18.9"
solana-sdk = "=1.18.9"
solana-transaction-status = "=1.18.9"
spl-token-2022 = "0.9.0"
thiserror = "1.0"
tokio = "1.21.2"
Expand All @@ -66,8 +66,8 @@ tonic-health = "0.10.2"
tracing = "0.1.37"
tracing-subscriber = "0.3.17"
vergen = "8.2.1"
yellowstone-grpc-client = { path = "yellowstone-grpc-client", version = "=1.14.0+solana.1.18.7" }
yellowstone-grpc-proto = { path = "yellowstone-grpc-proto", version = "=1.13.0+solana.1.18.7" }
yellowstone-grpc-client = { path = "yellowstone-grpc-client", version = "=1.15.0+solana.1.18.9" }
yellowstone-grpc-proto = { path = "yellowstone-grpc-proto", version = "=1.14.0+solana.1.18.9" }

[profile.release]
debug = true
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yellowstone-grpc-client-simple"
version = "1.12.0+solana.1.18.7"
version = "1.13.0+solana.1.18.9"
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
Expand Down
46 changes: 22 additions & 24 deletions examples/rust/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@ use {
solana_transaction_status::{EncodedTransactionWithStatusMeta, UiTransactionEncoding},
std::{collections::HashMap, env, fmt, fs::File, sync::Arc, time::Duration},
tokio::sync::Mutex,
yellowstone_grpc_client::{GeyserGrpcClient, GeyserGrpcClientError},
yellowstone_grpc_proto::{
prelude::{
subscribe_request_filter_accounts_filter::Filter as AccountsFilterDataOneof,
subscribe_request_filter_accounts_filter_memcmp::Data as AccountsFilterMemcmpOneof,
subscribe_update::UpdateOneof, CommitmentLevel, SubscribeRequest,
SubscribeRequestAccountsDataSlice, SubscribeRequestFilterAccounts,
SubscribeRequestFilterAccountsFilter, SubscribeRequestFilterAccountsFilterMemcmp,
SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta,
SubscribeRequestFilterEntry, SubscribeRequestFilterSlots,
SubscribeRequestFilterTransactions, SubscribeRequestPing, SubscribeUpdateAccount,
SubscribeUpdateTransaction, SubscribeUpdateTransactionStatus,
},
tonic::service::Interceptor,
yellowstone_grpc_client::{GeyserGrpcClient, GeyserGrpcClientError, Interceptor},
yellowstone_grpc_proto::prelude::{
subscribe_request_filter_accounts_filter::Filter as AccountsFilterDataOneof,
subscribe_request_filter_accounts_filter_memcmp::Data as AccountsFilterMemcmpOneof,
subscribe_update::UpdateOneof, CommitmentLevel, SubscribeRequest,
SubscribeRequestAccountsDataSlice, SubscribeRequestFilterAccounts,
SubscribeRequestFilterAccountsFilter, SubscribeRequestFilterAccountsFilterMemcmp,
SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta,
SubscribeRequestFilterEntry, SubscribeRequestFilterSlots,
SubscribeRequestFilterTransactions, SubscribeRequestPing, SubscribeUpdateAccount,
SubscribeUpdateTransaction, SubscribeUpdateTransactionStatus,
},
};

Expand Down Expand Up @@ -54,6 +51,16 @@ impl Args {
fn get_commitment(&self) -> Option<CommitmentLevel> {
Some(self.commitment.unwrap_or_default().into())
}

async fn connect(&self) -> anyhow::Result<GeyserGrpcClient<impl Interceptor>> {
GeyserGrpcClient::build_from_shared(self.endpoint.clone())?
.x_token(self.x_token.clone())?
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(10))
.connect()
.await
.map_err(Into::into)
}
}

#[derive(Debug, Clone, Copy, Default, ValueEnum)]
Expand Down Expand Up @@ -518,16 +525,7 @@ async fn main() -> anyhow::Result<()> {
drop(zero_attempts);

let commitment = args.get_commitment();
let mut client = GeyserGrpcClient::connect_with_timeout(
args.endpoint,
args.x_token,
None,
Some(Duration::from_secs(10)),
Some(Duration::from_secs(10)),
false,
)
.await
.map_err(|e| backoff::Error::transient(anyhow::Error::new(e)))?;
let mut client = args.connect().await.map_err(backoff::Error::transient)?;
info!("Connected");

match &args.action {
Expand Down
5 changes: 4 additions & 1 deletion examples/rust/src/bin/subscribe-ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ async fn main() -> anyhow::Result<()> {

let args = Args::parse();

let mut client = GeyserGrpcClient::connect(args.endpoint, args.x_token, None)?;
let mut client = GeyserGrpcClient::build_from_shared(args.endpoint)?
.x_token(args.x_token)?
.connect()
.await?;
let (mut subscribe_tx, mut stream) = client.subscribe().await?;

futures::try_join!(
Expand Down
5 changes: 4 additions & 1 deletion examples/rust/src/bin/tx-blocktime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ async fn main() -> anyhow::Result<()> {

let args = Args::parse();

let mut client = GeyserGrpcClient::connect(args.endpoint, args.x_token, None)?;
let mut client = GeyserGrpcClient::build_from_shared(args.endpoint)?
.x_token(args.x_token)?
.connect()
.await?;
let (mut subscribe_tx, mut stream) = client.subscribe().await?;

let commitment: CommitmentLevel = args.commitment.unwrap_or_default().into();
Expand Down
Loading

0 comments on commit d2c4659

Please sign in to comment.