wip
This commit is contained in:
parent
7e2fd7f97d
commit
497dfe0144
|
@ -842,6 +842,27 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "csv"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe"
|
||||||
|
dependencies = [
|
||||||
|
"csv-core",
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "csv-core"
|
||||||
|
version = "0.1.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctr"
|
name = "ctr"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -1242,6 +1263,7 @@ dependencies = [
|
||||||
"async-stream",
|
"async-stream",
|
||||||
"base64 0.21.5",
|
"base64 0.21.5",
|
||||||
"bincode",
|
"bincode",
|
||||||
|
"csv",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"futures",
|
"futures",
|
||||||
"itertools 0.10.5",
|
"itertools 0.10.5",
|
||||||
|
|
|
@ -30,6 +30,8 @@ derive_more = "0.99.17"
|
||||||
base64 = "0.21.5"
|
base64 = "0.21.5"
|
||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
|
|
||||||
|
csv = "1.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tracing-subscriber = "0.3.16"
|
tracing-subscriber = "0.3.16"
|
||||||
solana-logger = "1"
|
solana-logger = "1"
|
||||||
|
|
|
@ -4,6 +4,7 @@ use solana_sdk::clock::Slot;
|
||||||
use solana_sdk::commitment_config::CommitmentConfig;
|
use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::pin::pin;
|
use std::pin::pin;
|
||||||
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
|
||||||
use geyser_grpc_connector::grpc_subscription_autoreconnect_streams::create_geyser_reconnecting_stream;
|
use geyser_grpc_connector::grpc_subscription_autoreconnect_streams::create_geyser_reconnecting_stream;
|
||||||
use geyser_grpc_connector::grpcmultiplex_fastestwins::FromYellowstoneExtractor;
|
use geyser_grpc_connector::grpcmultiplex_fastestwins::FromYellowstoneExtractor;
|
||||||
|
@ -13,6 +14,7 @@ use tracing::warn;
|
||||||
use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof;
|
use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof;
|
||||||
use yellowstone_grpc_proto::geyser::SubscribeUpdate;
|
use yellowstone_grpc_proto::geyser::SubscribeUpdate;
|
||||||
use yellowstone_grpc_proto::prost::Message as _;
|
use yellowstone_grpc_proto::prost::Message as _;
|
||||||
|
use csv::Writer;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn start_example_blockmini_consumer(
|
fn start_example_blockmini_consumer(
|
||||||
|
@ -94,7 +96,7 @@ pub async fn main() {
|
||||||
|
|
||||||
let green_stream = create_geyser_reconnecting_stream(
|
let green_stream = create_geyser_reconnecting_stream(
|
||||||
config.clone(),
|
config.clone(),
|
||||||
GeyserFilter(CommitmentConfig::finalized()).blocks_and_txs(),
|
GeyserFilter(CommitmentConfig::processed()).accounts(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let blue_stream = create_geyser_reconnecting_stream(
|
let blue_stream = create_geyser_reconnecting_stream(
|
||||||
|
@ -103,13 +105,23 @@ pub async fn main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
let mut wtr = csv::Writer::from_path("accounts-mainnet.csv").unwrap();
|
||||||
|
|
||||||
let mut green_stream = pin!(green_stream);
|
let mut green_stream = pin!(green_stream);
|
||||||
while let Some(message) = green_stream.next().await {
|
while let Some(message) = green_stream.next().await {
|
||||||
match message {
|
match message {
|
||||||
Message::GeyserSubscribeUpdate(subscriber_update) => {
|
Message::GeyserSubscribeUpdate(subscriber_update) => {
|
||||||
let mapped = map_block_update(*subscriber_update);
|
match subscriber_update.update_oneof {
|
||||||
if let Some(slot) = mapped {
|
Some(UpdateOneof::Account(update)) => {
|
||||||
info!("got update (green)!!! slot: {}", slot);
|
info!("got update (green)!!! slot: {}", update.slot);
|
||||||
|
let key = update.account.unwrap().pubkey;
|
||||||
|
let bytes: [u8; 32] =
|
||||||
|
key.try_into().unwrap_or(Pubkey::default().to_bytes());
|
||||||
|
let pubkey = Pubkey::new_from_array(bytes);
|
||||||
|
wtr.write_record(&[pubkey.to_string()]).unwrap();
|
||||||
|
wtr.flush().unwrap();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Connecting(attempt) => {
|
Message::Connecting(attempt) => {
|
||||||
|
|
29
src/lib.rs
29
src/lib.rs
|
@ -2,10 +2,7 @@ use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use yellowstone_grpc_proto::geyser::{
|
use yellowstone_grpc_proto::geyser::{CommitmentLevel, SubscribeRequest, SubscribeRequestFilterAccounts, SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta, SubscribeRequestFilterSlots, SubscribeUpdate};
|
||||||
CommitmentLevel, SubscribeRequest, SubscribeRequestFilterBlocks,
|
|
||||||
SubscribeRequestFilterBlocksMeta, SubscribeRequestFilterSlots, SubscribeUpdate,
|
|
||||||
};
|
|
||||||
use yellowstone_grpc_proto::tonic::transport::ClientTlsConfig;
|
use yellowstone_grpc_proto::tonic::transport::ClientTlsConfig;
|
||||||
|
|
||||||
pub mod channel_plugger;
|
pub mod channel_plugger;
|
||||||
|
@ -150,6 +147,30 @@ impl GeyserFilter {
|
||||||
ping: None,
|
ping: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn accounts(&self) -> SubscribeRequest {
|
||||||
|
let mut accounts_subs = HashMap::new();
|
||||||
|
accounts_subs.insert(
|
||||||
|
"client".to_string(),
|
||||||
|
SubscribeRequestFilterAccounts {
|
||||||
|
account: vec![],
|
||||||
|
owner: vec![],
|
||||||
|
filters: vec![],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
SubscribeRequest {
|
||||||
|
slots: HashMap::new(),
|
||||||
|
accounts: accounts_subs,
|
||||||
|
transactions: HashMap::new(),
|
||||||
|
entry: Default::default(),
|
||||||
|
blocks: Default::default(),
|
||||||
|
blocks_meta: HashMap::new(),
|
||||||
|
commitment: Some(map_commitment_level(self.0) as i32),
|
||||||
|
accounts_data_slice: Default::default(),
|
||||||
|
ping: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_commitment_level(commitment_config: CommitmentConfig) -> CommitmentLevel {
|
fn map_commitment_level(commitment_config: CommitmentConfig) -> CommitmentLevel {
|
||||||
|
|
Loading…
Reference in New Issue