Skip to content

Commit

Permalink
proto: add mod convert_to, convert_from (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Oct 3, 2023
1 parent a6cb542 commit f559fa8
Show file tree
Hide file tree
Showing 12 changed files with 602 additions and 288 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The minor version will be incremented upon a breaking change and the patch versi

### Features

- proto: add mod `convert_to`, `convert_from` ([#190](https://github.com/rpcpool/yellowstone-grpc/pull/190)).

### Fixes

### Breaking
Expand Down
12 changes: 8 additions & 4 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[workspace]
members = [
"examples/rust", # 1.9.0+solana.1.16.14
"yellowstone-grpc-client", # 1.10.0+solana.1.16.14
"yellowstone-grpc-geyser", # 1.8.0+solana.1.16.14
"examples/rust", # 1.10.0+solana.1.16.14
"yellowstone-grpc-client", # 1.11.0+solana.1.16.14
"yellowstone-grpc-geyser", # 1.9.0+solana.1.16.14
"yellowstone-grpc-kafka", # 1.0.0+solana.1.16.14
"yellowstone-grpc-proto", # 1.9.0+solana.1.16.14
"yellowstone-grpc-proto", # 1.10.0+solana.1.16.14
]

[profile.release]
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.9.0+solana.1.16.14"
version = "1.10.0+solana.1.16.14"
authors = ["Triton One"]
edition = "2021"
publish = false
Expand Down
4 changes: 2 additions & 2 deletions yellowstone-grpc-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yellowstone-grpc-client"
version = "1.10.0+solana.1.16.14"
version = "1.11.0+solana.1.16.14"
authors = ["Triton One"]
edition = "2021"
description = "Yellowstone gRPC Geyser Simple Client"
Expand All @@ -16,7 +16,7 @@ http = "0.2.8"
thiserror = "1.0"
tonic = { version = "0.9.2", features = ["gzip", "tls", "tls-roots"] }
tonic-health = "0.9.2"
yellowstone-grpc-proto = { path = "../yellowstone-grpc-proto", version = "1.9.0+solana.1.16.14" }
yellowstone-grpc-proto = { path = "../yellowstone-grpc-proto", version = "1.10.0+solana.1.16.14" }

[dev-dependencies]
tokio = { version = "1.21.2", features = ["macros"] }
2 changes: 1 addition & 1 deletion yellowstone-grpc-geyser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yellowstone-grpc-geyser"
version = "1.8.0+solana.1.16.14"
version = "1.9.0+solana.1.16.14"
authors = ["Triton One"]
edition = "2021"
description = "Yellowstone gRPC Geyser Plugin"
Expand Down
18 changes: 9 additions & 9 deletions yellowstone-grpc-geyser/src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ use {
Message, MessageAccount, MessageBlock, MessageBlockMeta, MessageEntry, MessageRef,
MessageSlot, MessageTransaction,
},
proto::{
subscribe_request_filter_accounts_filter::Filter as AccountsFilterDataOneof,
subscribe_request_filter_accounts_filter_memcmp::Data as AccountsFilterMemcmpOneof,
CommitmentLevel, SubscribeRequest, SubscribeRequestAccountsDataSlice,
SubscribeRequestFilterAccounts, SubscribeRequestFilterAccountsFilter,
SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta,
SubscribeRequestFilterEntry, SubscribeRequestFilterSlots,
SubscribeRequestFilterTransactions, SubscribeUpdate,
},
},
base64::{engine::general_purpose::STANDARD as base64_engine, Engine},
solana_sdk::{pubkey::Pubkey, signature::Signature},
Expand All @@ -27,6 +18,15 @@ use {
iter::FromIterator,
str::FromStr,
},
yellowstone_grpc_proto::prelude::{
subscribe_request_filter_accounts_filter::Filter as AccountsFilterDataOneof,
subscribe_request_filter_accounts_filter_memcmp::Data as AccountsFilterMemcmpOneof,
CommitmentLevel, SubscribeRequest, SubscribeRequestAccountsDataSlice,
SubscribeRequestFilterAccounts, SubscribeRequestFilterAccountsFilter,
SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta,
SubscribeRequestFilterEntry, SubscribeRequestFilterSlots,
SubscribeRequestFilterTransactions, SubscribeUpdate,
},
};

#[derive(Debug, Clone)]
Expand Down
46 changes: 22 additions & 24 deletions yellowstone-grpc-geyser/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ use {
config::{ConfigBlockFailAction, ConfigGrpc},
filters::{Filter, FilterAccountsDataSlice},
prom::{self, CONNECTIONS_TOTAL, MESSAGE_QUEUE_SIZE},
proto::{
self,
geyser_server::{Geyser, GeyserServer},
subscribe_update::UpdateOneof,
CommitmentLevel, GetBlockHeightRequest, GetBlockHeightResponse,
GetLatestBlockhashRequest, GetLatestBlockhashResponse, GetSlotRequest, GetSlotResponse,
GetVersionRequest, GetVersionResponse, IsBlockhashValidRequest,
IsBlockhashValidResponse, PingRequest, PongResponse, SubscribeRequest, SubscribeUpdate,
SubscribeUpdateAccount, SubscribeUpdateAccountInfo, SubscribeUpdateBlock,
SubscribeUpdateBlockMeta, SubscribeUpdateEntry, SubscribeUpdatePing,
SubscribeUpdateSlot, SubscribeUpdateTransaction, SubscribeUpdateTransactionInfo,
},
version::VERSION,
},
log::{error, info},
Expand Down Expand Up @@ -51,6 +39,20 @@ use {
Request, Response, Result as TonicResult, Status, Streaming,
},
tonic_health::server::health_reporter,
yellowstone_grpc_proto::{
convert_to,
prelude::{
geyser_server::{Geyser, GeyserServer},
subscribe_update::UpdateOneof,
CommitmentLevel, GetBlockHeightRequest, GetBlockHeightResponse,
GetLatestBlockhashRequest, GetLatestBlockhashResponse, GetSlotRequest, GetSlotResponse,
GetVersionRequest, GetVersionResponse, IsBlockhashValidRequest,
IsBlockhashValidResponse, PingRequest, PongResponse, SubscribeRequest, SubscribeUpdate,
SubscribeUpdateAccount, SubscribeUpdateAccountInfo, SubscribeUpdateBlock,
SubscribeUpdateBlockMeta, SubscribeUpdateEntry, SubscribeUpdatePing,
SubscribeUpdateSlot, SubscribeUpdateTransaction, SubscribeUpdateTransactionInfo,
},
},
};

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -155,8 +157,8 @@ impl MessageTransactionInfo {
SubscribeUpdateTransactionInfo {
signature: self.signature.as_ref().into(),
is_vote: self.is_vote,
transaction: Some(proto::convert::create_transaction(&self.transaction)),
meta: Some(proto::convert::create_transaction_meta(&self.meta)),
transaction: Some(convert_to::create_transaction(&self.transaction)),
meta: Some(convert_to::create_transaction_meta(&self.meta)),
index: self.index as u64,
}
}
Expand Down Expand Up @@ -412,11 +414,9 @@ impl<'a> MessageRef<'a> {
Self::Block(message) => UpdateOneof::Block(SubscribeUpdateBlock {
slot: message.slot,
blockhash: message.blockhash.clone(),
rewards: Some(proto::convert::create_rewards(message.rewards.as_slice())),
block_time: message.block_time.map(proto::convert::create_timestamp),
block_height: message
.block_height
.map(proto::convert::create_block_height),
rewards: Some(convert_to::create_rewards(message.rewards.as_slice())),
block_time: message.block_time.map(convert_to::create_timestamp),
block_height: message.block_height.map(convert_to::create_block_height),
parent_slot: message.parent_slot,
parent_blockhash: message.parent_blockhash.clone(),
executed_transaction_count: message.executed_transaction_count,
Expand All @@ -441,11 +441,9 @@ impl<'a> MessageRef<'a> {
Self::BlockMeta(message) => UpdateOneof::BlockMeta(SubscribeUpdateBlockMeta {
slot: message.slot,
blockhash: message.blockhash.clone(),
rewards: Some(proto::convert::create_rewards(message.rewards.as_slice())),
block_time: message.block_time.map(proto::convert::create_timestamp),
block_height: message
.block_height
.map(proto::convert::create_block_height),
rewards: Some(convert_to::create_rewards(message.rewards.as_slice())),
block_time: message.block_time.map(convert_to::create_timestamp),
block_height: message.block_height.map(convert_to::create_block_height),
parent_slot: message.parent_slot,
parent_blockhash: message.parent_blockhash.clone(),
executed_transaction_count: message.executed_transaction_count,
Expand Down
1 change: 0 additions & 1 deletion yellowstone-grpc-geyser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ pub mod filters;
pub mod grpc;
pub mod plugin;
pub mod prom;
pub mod proto;
pub mod version;
Loading

0 comments on commit f559fa8

Please sign in to comment.