write account sizes to CSV

This commit is contained in:
GroovieGermanikus 2024-04-16 13:19:09 +02:00
parent 3447900b7b
commit 9086defedb
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
3 changed files with 33 additions and 2 deletions

22
Cargo.lock generated
View File

@ -981,6 +981,27 @@ dependencies = [
"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]]
name = "ctr"
version = "0.8.0"
@ -5220,6 +5241,7 @@ dependencies = [
"cargo-lock",
"clap",
"crossbeam-channel",
"csv",
"futures",
"git-version",
"hostname",

View File

@ -42,6 +42,8 @@ tonic = { workspace = true, features = ["gzip", "tls", "tls-roots"] }
tonic-health = { workspace = true }
yellowstone-grpc-proto = { workspace = true }
csv = "1.3.0"
[build-dependencies]
anyhow = { workspace = true }
cargo-lock = { workspace = true }

View File

@ -1,5 +1,8 @@
use log::warn;
use tokio::sync::mpsc::error::SendError;
use std::cell::RefCell;
use std::fs::File;
use std::sync::Mutex;
use csv::Writer;
use log::{info, warn};
use {
crate::{
config::Config,
@ -32,6 +35,7 @@ pub struct PluginInner {
grpc_channel: mpsc::UnboundedSender<Message>,
grpc_shutdown: Arc<Notify>,
prometheus: PrometheusService,
csv_writer: Arc<Mutex<Writer<File>>>,
}
impl PluginInner {
@ -100,12 +104,15 @@ impl GeyserPlugin for Plugin {
))
})?;
let mut csv_writer = Writer::from_path("account-sizes.csv").expect("must be able to use CSV");
self.inner = Some(PluginInner {
runtime,
snapshot_channel,
grpc_channel,
grpc_shutdown,
prometheus,
csv_writer: Arc::new(Mutex::new(csv_writer)),
});
Ok(())