Add geyser blockV2 (#36)
This commit is contained in:
parent
3828153d28
commit
f370f0e23e
|
@ -2475,8 +2475,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-account-decoder"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b04c1316932017ae5f947e83d77cc0356c4a395130a480cdc17ffb0570a0c115"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"base64 0.13.1",
|
||||
|
@ -2500,8 +2499,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-address-lookup-table-program"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5be490ed850c99286a4e4ba169ce20695336fe666c56bd823bfd8db689d23a58"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytemuck",
|
||||
|
@ -2510,9 +2508,9 @@ dependencies = [
|
|||
"num-traits",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-program",
|
||||
"solana-frozen-abi 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-frozen-abi-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-program 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
"thiserror",
|
||||
|
@ -2521,8 +2519,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-config-program"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb275d80a482134f0f0c5439b0c40ba3f04bef70dbc46c0e47f6107f6ae482a8"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
|
@ -2561,7 +2558,40 @@ dependencies = [
|
|||
"serde_derive",
|
||||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-frozen-abi-macro 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"subtle",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.14.13"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"blake3",
|
||||
"block-buffer 0.9.0",
|
||||
"bs58",
|
||||
"bv",
|
||||
"byteorder",
|
||||
"cc",
|
||||
"either",
|
||||
"generic-array",
|
||||
"getrandom 0.1.16",
|
||||
"hashbrown 0.12.3",
|
||||
"im",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"memmap2",
|
||||
"once_cell",
|
||||
"rand_core 0.6.4",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"solana-frozen-abi-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"subtle",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -2578,9 +2608,20 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.14.13"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-geyser-grpc"
|
||||
version = "0.4.1+solana.1.14.13"
|
||||
version = "0.5.0+solana.1.14.13"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
@ -2610,8 +2651,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-geyser-plugin-interface"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99f7216b62034ddaa04ea7fae38738d6bd1de2927ca3bdb42fafcd471c9c6751"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"log",
|
||||
"solana-sdk",
|
||||
|
@ -2622,8 +2662,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "447d16a70a1b5383736ef44801050c0e1affd022303b22ed899352f958c2de4b"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -2633,8 +2672,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-measure"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2400d2534a19f7605c5059060edea0499600a223f1a1f6a4b172666c04946a77"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"log",
|
||||
"solana-sdk",
|
||||
|
@ -2643,8 +2681,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-metrics"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68aaa3d683945dc3b6ca38923ef952ca1f96a27b61f898a1ddf9f4cd79f2df92"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"gethostname",
|
||||
|
@ -2694,9 +2731,57 @@ dependencies = [
|
|||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"sha3 0.10.6",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-sdk-macro",
|
||||
"solana-frozen-abi 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-frozen-abi-macro 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-sdk-macro 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thiserror",
|
||||
"tiny-bip39",
|
||||
"wasm-bindgen",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-program"
|
||||
version = "1.14.13"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"bincode",
|
||||
"bitflags",
|
||||
"blake3",
|
||||
"borsh",
|
||||
"borsh-derive",
|
||||
"bs58",
|
||||
"bv",
|
||||
"bytemuck",
|
||||
"cc",
|
||||
"console_error_panic_hook",
|
||||
"console_log",
|
||||
"curve25519-dalek",
|
||||
"getrandom 0.2.8",
|
||||
"itertools",
|
||||
"js-sys",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"libsecp256k1",
|
||||
"log",
|
||||
"memoffset 0.6.5",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"parking_lot",
|
||||
"rand 0.7.3",
|
||||
"rand_chacha 0.2.2",
|
||||
"rustc_version",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"sha3 0.10.6",
|
||||
"solana-frozen-abi 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-frozen-abi-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-sdk-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"thiserror",
|
||||
"tiny-bip39",
|
||||
"wasm-bindgen",
|
||||
|
@ -2706,8 +2791,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-program-runtime"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4d12047608bac77fca000e18f7a2df3c7fa90656d7c7d387b1cd7faf18b238c"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"bincode",
|
||||
|
@ -2722,8 +2806,8 @@ dependencies = [
|
|||
"rand 0.7.3",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-frozen-abi 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-frozen-abi-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-measure",
|
||||
"solana-metrics",
|
||||
"solana-sdk",
|
||||
|
@ -2733,8 +2817,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-sdk"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "390e7481c56dda2ceab2652beeda30a533e9667b34861a2eb4eec92fa1d826d7"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"base64 0.13.1",
|
||||
|
@ -2771,11 +2854,11 @@ dependencies = [
|
|||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"sha3 0.10.6",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-frozen-abi 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-frozen-abi-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-logger",
|
||||
"solana-program",
|
||||
"solana-sdk-macro",
|
||||
"solana-program 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-sdk-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"thiserror",
|
||||
"uriparse",
|
||||
"wasm-bindgen",
|
||||
|
@ -2794,11 +2877,22 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.14.13"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-transaction-status"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c5bbdaed99403e4a17763bee60c1e0e3418524503c72b514ebff62efbcc9d33"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"base64 0.13.1",
|
||||
|
@ -2826,8 +2920,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-vote-program"
|
||||
version = "1.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81ab9ff8928282cb42871a370435dd4713f700854801afb476cf63066f1337db"
|
||||
source = "git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2#c9db2ceb898985869fe565044e324e950fdbb535"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
@ -2836,8 +2929,8 @@ dependencies = [
|
|||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-frozen-abi 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-frozen-abi-macro 1.14.13 (git+https://github.com/fanatid/solana.git?tag=v1.14.13-geyser-block-v2)",
|
||||
"solana-metrics",
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
|
@ -2868,7 +2961,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"sha3 0.9.1",
|
||||
"solana-program",
|
||||
"solana-program 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-sdk",
|
||||
"subtle",
|
||||
"thiserror",
|
||||
|
@ -2891,7 +2984,7 @@ dependencies = [
|
|||
"borsh",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"solana-program",
|
||||
"solana-program 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spl-token",
|
||||
"spl-token-2022",
|
||||
"thiserror",
|
||||
|
@ -2903,7 +2996,7 @@ version = "3.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd0dc6f70db6bacea7ff25870b016a65ba1d1b6013536f08e4fd79a8f9005325"
|
||||
dependencies = [
|
||||
"solana-program",
|
||||
"solana-program 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2917,7 +3010,7 @@ dependencies = [
|
|||
"num-derive",
|
||||
"num-traits",
|
||||
"num_enum",
|
||||
"solana-program",
|
||||
"solana-program 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -2932,7 +3025,7 @@ dependencies = [
|
|||
"num-derive",
|
||||
"num-traits",
|
||||
"num_enum",
|
||||
"solana-program",
|
||||
"solana-program 1.14.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-zk-token-sdk",
|
||||
"spl-memo",
|
||||
"spl-token",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "solana-geyser-grpc"
|
||||
version = "0.4.1+solana.1.14.13"
|
||||
version = "0.5.0+solana.1.14.13"
|
||||
authors = ["Triton One"]
|
||||
edition = "2021"
|
||||
|
||||
|
@ -35,6 +35,12 @@ protobuf-src = "1.1.0"
|
|||
tonic-build = "0.8.2"
|
||||
vergen = "=7.2.1"
|
||||
|
||||
[patch.crates-io]
|
||||
solana-geyser-plugin-interface = { git = "https://github.com/fanatid/solana.git", tag = "v1.14.13-geyser-block-v2" }
|
||||
solana-logger = { git = "https://github.com/fanatid/solana.git", tag = "v1.14.13-geyser-block-v2" }
|
||||
solana-sdk = { git = "https://github.com/fanatid/solana.git", tag = "v1.14.13-geyser-block-v2" }
|
||||
solana-transaction-status = { git = "https://github.com/fanatid/solana.git", tag = "v1.14.13-geyser-block-v2" }
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
lto = true
|
||||
|
|
|
@ -96,6 +96,8 @@ message SubscribeUpdateBlock {
|
|||
solana.storage.ConfirmedBlock.UnixTimestamp block_time = 4;
|
||||
solana.storage.ConfirmedBlock.BlockHeight block_height = 5;
|
||||
repeated SubscribeUpdateTransactionInfo transactions = 6;
|
||||
uint64 parent_slot = 7;
|
||||
string parent_blockhash = 8;
|
||||
}
|
||||
|
||||
message SubscribeUpdateBlockMeta {
|
||||
|
@ -104,6 +106,9 @@ message SubscribeUpdateBlockMeta {
|
|||
solana.storage.ConfirmedBlock.Rewards rewards = 3;
|
||||
solana.storage.ConfirmedBlock.UnixTimestamp block_time = 4;
|
||||
solana.storage.ConfirmedBlock.BlockHeight block_height = 5;
|
||||
uint64 parent_slot = 6;
|
||||
string parent_blockhash = 7;
|
||||
uint64 executed_transaction_count = 8;
|
||||
}
|
||||
|
||||
message SubscribeUpdatePing {}
|
||||
|
|
112
src/grpc.rs
112
src/grpc.rs
|
@ -14,8 +14,7 @@ use {
|
|||
},
|
||||
log::*,
|
||||
solana_geyser_plugin_interface::geyser_plugin_interface::{
|
||||
ReplicaAccountInfoVersions, ReplicaBlockInfoVersions, ReplicaTransactionInfoVersions,
|
||||
SlotStatus,
|
||||
ReplicaAccountInfoV2, ReplicaBlockInfoV2, ReplicaTransactionInfoV2, SlotStatus,
|
||||
},
|
||||
solana_sdk::{
|
||||
clock::UnixTimestamp, pubkey::Pubkey, signature::Signature,
|
||||
|
@ -58,23 +57,18 @@ pub struct MessageAccount {
|
|||
pub is_startup: bool,
|
||||
}
|
||||
|
||||
impl<'a> From<(ReplicaAccountInfoVersions<'a>, u64, bool)> for MessageAccount {
|
||||
fn from((account, slot, is_startup): (ReplicaAccountInfoVersions<'a>, u64, bool)) -> Self {
|
||||
impl<'a> From<(&'a ReplicaAccountInfoV2<'a>, u64, bool)> for MessageAccount {
|
||||
fn from((account, slot, is_startup): (&'a ReplicaAccountInfoV2<'a>, u64, bool)) -> Self {
|
||||
Self {
|
||||
account: match account {
|
||||
ReplicaAccountInfoVersions::V0_0_1(_info) => {
|
||||
unreachable!("ReplicaAccountInfoVersions::V0_0_1 is not supported")
|
||||
}
|
||||
ReplicaAccountInfoVersions::V0_0_2(info) => MessageAccountInfo {
|
||||
pubkey: Pubkey::new(info.pubkey),
|
||||
lamports: info.lamports,
|
||||
owner: Pubkey::new(info.owner),
|
||||
executable: info.executable,
|
||||
rent_epoch: info.rent_epoch,
|
||||
data: info.data.into(),
|
||||
write_version: info.write_version,
|
||||
txn_signature: info.txn_signature.cloned(),
|
||||
},
|
||||
account: MessageAccountInfo {
|
||||
pubkey: Pubkey::new(account.pubkey),
|
||||
lamports: account.lamports,
|
||||
owner: Pubkey::new(account.owner),
|
||||
executable: account.executable,
|
||||
rent_epoch: account.rent_epoch,
|
||||
data: account.data.into(),
|
||||
write_version: account.write_version,
|
||||
txn_signature: account.txn_signature.cloned(),
|
||||
},
|
||||
slot,
|
||||
is_startup,
|
||||
|
@ -130,20 +124,15 @@ pub struct MessageTransaction {
|
|||
pub slot: u64,
|
||||
}
|
||||
|
||||
impl<'a> From<(ReplicaTransactionInfoVersions<'a>, u64)> for MessageTransaction {
|
||||
fn from((transaction, slot): (ReplicaTransactionInfoVersions<'a>, u64)) -> Self {
|
||||
impl<'a> From<(&'a ReplicaTransactionInfoV2<'a>, u64)> for MessageTransaction {
|
||||
fn from((transaction, slot): (&'a ReplicaTransactionInfoV2<'a>, u64)) -> Self {
|
||||
Self {
|
||||
transaction: match transaction {
|
||||
ReplicaTransactionInfoVersions::V0_0_1(_info) => {
|
||||
unreachable!("ReplicaAccountInfoVersions::V0_0_1 is not supported")
|
||||
}
|
||||
ReplicaTransactionInfoVersions::V0_0_2(info) => MessageTransactionInfo {
|
||||
signature: *info.signature,
|
||||
is_vote: info.is_vote,
|
||||
transaction: info.transaction.clone(),
|
||||
meta: info.transaction_status_meta.clone(),
|
||||
index: info.index,
|
||||
},
|
||||
transaction: MessageTransactionInfo {
|
||||
signature: *transaction.signature,
|
||||
is_vote: transaction.is_vote,
|
||||
transaction: transaction.transaction.clone(),
|
||||
meta: transaction.transaction_status_meta.clone(),
|
||||
index: transaction.index,
|
||||
},
|
||||
slot,
|
||||
}
|
||||
|
@ -152,7 +141,9 @@ impl<'a> From<(ReplicaTransactionInfoVersions<'a>, u64)> for MessageTransaction
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct MessageBlock {
|
||||
pub parent_slot: u64,
|
||||
pub slot: u64,
|
||||
pub parent_blockhash: String,
|
||||
pub blockhash: String,
|
||||
pub rewards: Vec<Reward>,
|
||||
pub block_time: Option<UnixTimestamp>,
|
||||
|
@ -160,50 +151,46 @@ pub struct MessageBlock {
|
|||
pub transactions: Vec<MessageTransactionInfo>,
|
||||
}
|
||||
|
||||
impl<'a>
|
||||
From<(
|
||||
&'a ReplicaBlockInfoVersions<'a>,
|
||||
Vec<MessageTransactionInfo>,
|
||||
)> for MessageBlock
|
||||
{
|
||||
impl<'a> From<(&'a ReplicaBlockInfoV2<'a>, Vec<MessageTransactionInfo>)> for MessageBlock {
|
||||
fn from(
|
||||
(blockinfo, transactions): (
|
||||
&'a ReplicaBlockInfoVersions<'a>,
|
||||
Vec<MessageTransactionInfo>,
|
||||
),
|
||||
(blockinfo, transactions): (&'a ReplicaBlockInfoV2<'a>, Vec<MessageTransactionInfo>),
|
||||
) -> Self {
|
||||
match blockinfo {
|
||||
ReplicaBlockInfoVersions::V0_0_1(info) => Self {
|
||||
slot: info.slot,
|
||||
blockhash: info.blockhash.to_string(),
|
||||
rewards: info.rewards.into(),
|
||||
block_time: info.block_time,
|
||||
block_height: info.block_height,
|
||||
transactions,
|
||||
},
|
||||
Self {
|
||||
parent_slot: blockinfo.parent_slot,
|
||||
slot: blockinfo.slot,
|
||||
blockhash: blockinfo.blockhash.to_string(),
|
||||
parent_blockhash: blockinfo.parent_blockhash.to_string(),
|
||||
rewards: blockinfo.rewards.into(),
|
||||
block_time: blockinfo.block_time,
|
||||
block_height: blockinfo.block_height,
|
||||
transactions,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MessageBlockMeta {
|
||||
pub parent_slot: u64,
|
||||
pub slot: u64,
|
||||
pub parent_blockhash: String,
|
||||
pub blockhash: String,
|
||||
pub rewards: Vec<Reward>,
|
||||
pub block_time: Option<UnixTimestamp>,
|
||||
pub block_height: Option<u64>,
|
||||
pub executed_transaction_count: u64,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ReplicaBlockInfoVersions<'a>> for MessageBlockMeta {
|
||||
fn from(blockinfo: &'a ReplicaBlockInfoVersions<'a>) -> Self {
|
||||
match blockinfo {
|
||||
ReplicaBlockInfoVersions::V0_0_1(info) => Self {
|
||||
slot: info.slot,
|
||||
blockhash: info.blockhash.to_string(),
|
||||
rewards: info.rewards.into(),
|
||||
block_time: info.block_time,
|
||||
block_height: info.block_height,
|
||||
},
|
||||
impl<'a> From<&'a ReplicaBlockInfoV2<'a>> for MessageBlockMeta {
|
||||
fn from(blockinfo: &'a ReplicaBlockInfoV2<'a>) -> Self {
|
||||
Self {
|
||||
parent_slot: blockinfo.parent_slot,
|
||||
slot: blockinfo.slot,
|
||||
parent_blockhash: blockinfo.parent_blockhash.to_string(),
|
||||
blockhash: blockinfo.blockhash.to_string(),
|
||||
rewards: blockinfo.rewards.into(),
|
||||
block_time: blockinfo.block_time,
|
||||
block_height: blockinfo.block_height,
|
||||
executed_transaction_count: blockinfo.executed_transaction_count,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,6 +237,8 @@ impl From<&Message> for UpdateOneof {
|
|||
block_time: message.block_time.map(|v| v.into()),
|
||||
block_height: message.block_height.map(|v| v.into()),
|
||||
transactions: message.transactions.iter().map(Into::into).collect(),
|
||||
parent_slot: message.parent_slot,
|
||||
parent_blockhash: message.parent_blockhash.clone(),
|
||||
}),
|
||||
Message::BlockMeta(message) => UpdateOneof::BlockMeta(SubscribeUpdateBlockMeta {
|
||||
slot: message.slot,
|
||||
|
@ -257,6 +246,9 @@ impl From<&Message> for UpdateOneof {
|
|||
rewards: Some(message.rewards.as_slice().into()),
|
||||
block_time: message.block_time.map(|v| v.into()),
|
||||
block_height: message.block_height.map(|v| v.into()),
|
||||
parent_slot: message.parent_slot,
|
||||
parent_blockhash: message.parent_blockhash.clone(),
|
||||
executed_transaction_count: message.executed_transaction_count,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,13 @@ impl GeyserPlugin for Plugin {
|
|||
is_startup: bool,
|
||||
) -> PluginResult<()> {
|
||||
self.with_inner(|inner| {
|
||||
let account = match account {
|
||||
ReplicaAccountInfoVersions::V0_0_1(_info) => {
|
||||
unreachable!("ReplicaAccountInfoVersions::V0_0_1 is not supported")
|
||||
}
|
||||
ReplicaAccountInfoVersions::V0_0_2(info) => info,
|
||||
};
|
||||
|
||||
let message = Message::Account((account, slot, is_startup).into());
|
||||
let _ = inner.grpc_channel.send(message);
|
||||
Ok(())
|
||||
|
@ -137,6 +144,13 @@ impl GeyserPlugin for Plugin {
|
|||
slot: u64,
|
||||
) -> PluginResult<()> {
|
||||
self.with_inner(|inner| {
|
||||
let transaction = match transaction {
|
||||
ReplicaTransactionInfoVersions::V0_0_1(_info) => {
|
||||
unreachable!("ReplicaAccountInfoVersions::V0_0_1 is not supported")
|
||||
}
|
||||
ReplicaTransactionInfoVersions::V0_0_2(info) => info,
|
||||
};
|
||||
|
||||
let msg_tx: MessageTransaction = (transaction, slot).into();
|
||||
match &mut inner.transactions {
|
||||
Some((current_slot, transactions)) if *current_slot == slot => {
|
||||
|
@ -168,21 +182,38 @@ impl GeyserPlugin for Plugin {
|
|||
blockinfo: ReplicaBlockInfoVersions<'_>,
|
||||
) -> PluginResult<()> {
|
||||
self.with_inner(|inner| {
|
||||
let ReplicaBlockInfoVersions::V0_0_1(block) = &blockinfo;
|
||||
let blockinfo = match blockinfo {
|
||||
ReplicaBlockInfoVersions::V0_0_1(_info) => {
|
||||
unreachable!("ReplicaBlockInfoVersions::V0_0_1 is not supported")
|
||||
}
|
||||
ReplicaBlockInfoVersions::V0_0_2(info) => info,
|
||||
};
|
||||
|
||||
let transactions = match inner.transactions.take() {
|
||||
Some((slot, transactions)) if slot == block.slot => Ok(transactions),
|
||||
Some((slot, _)) => Err(format!(
|
||||
"invalid transactions for block {}, found {}",
|
||||
block.slot, slot
|
||||
Some((slot, _transactions)) if slot != blockinfo.slot => Err(format!(
|
||||
"invalid transactions for block {}, expected block {}",
|
||||
blockinfo.slot, slot
|
||||
)),
|
||||
None => Err(format!("no transactions for block {}", block.slot)),
|
||||
Some((_slot, transactions))
|
||||
if transactions.len() != blockinfo.executed_transaction_count as usize =>
|
||||
{
|
||||
Err(format!(
|
||||
"invalid count of transactions for block {}, collected {}, expected {}",
|
||||
blockinfo.slot,
|
||||
transactions.len(),
|
||||
blockinfo.executed_transaction_count
|
||||
))
|
||||
}
|
||||
Some((_slot, transactions)) => Ok(transactions),
|
||||
None if blockinfo.executed_transaction_count == 0 => Ok(vec![]),
|
||||
None => Err(format!("no transactions for block {}", blockinfo.slot)),
|
||||
};
|
||||
|
||||
match transactions {
|
||||
Ok(transactions) => {
|
||||
let message = Message::Block((&blockinfo, transactions).into());
|
||||
let message = Message::Block((blockinfo, transactions).into());
|
||||
let _ = inner.grpc_channel.send(message);
|
||||
let message = Message::BlockMeta((&blockinfo).into());
|
||||
let message = Message::BlockMeta((blockinfo).into());
|
||||
let _ = inner.grpc_channel.send(message);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue