2022-03-23 00:19:19 -07:00
|
|
|
pub mod chain_data;
|
2022-03-28 10:58:14 -07:00
|
|
|
pub mod fill_event_filter;
|
2023-02-03 03:39:53 -08:00
|
|
|
pub mod fill_event_postgres_target;
|
2021-11-08 00:40:03 -08:00
|
|
|
pub mod grpc_plugin_source;
|
2022-03-23 00:19:19 -07:00
|
|
|
pub mod memory_target;
|
2021-11-08 11:15:46 -08:00
|
|
|
pub mod metrics;
|
2023-02-03 03:39:53 -08:00
|
|
|
pub mod orderbook_filter;
|
2021-11-09 05:32:58 -08:00
|
|
|
pub mod postgres_types_numeric;
|
2023-02-02 23:15:58 -08:00
|
|
|
pub mod serum;
|
2021-11-08 00:40:03 -08:00
|
|
|
pub mod websocket_source;
|
2021-11-04 01:57:55 -07:00
|
|
|
|
2022-03-23 00:19:19 -07:00
|
|
|
pub use chain_data::SlotStatus;
|
2023-02-03 03:39:53 -08:00
|
|
|
use serde::{ser::SerializeStruct, Serialize, Serializer};
|
2022-03-23 00:19:19 -07:00
|
|
|
|
2021-11-02 05:22:13 -07:00
|
|
|
use {
|
|
|
|
serde_derive::Deserialize,
|
2021-11-02 06:35:45 -07:00
|
|
|
solana_sdk::{account::Account, pubkey::Pubkey},
|
2021-11-02 05:22:13 -07:00
|
|
|
};
|
2021-11-01 02:34:25 -07:00
|
|
|
|
|
|
|
trait AnyhowWrap {
|
|
|
|
type Value;
|
|
|
|
fn map_err_anyhow(self) -> anyhow::Result<Self::Value>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T, E: std::fmt::Debug> AnyhowWrap for Result<T, E> {
|
|
|
|
type Value = T;
|
|
|
|
fn map_err_anyhow(self) -> anyhow::Result<Self::Value> {
|
|
|
|
self.map_err(|err| anyhow::anyhow!("{:?}", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, PartialEq, Debug)]
|
|
|
|
pub struct AccountWrite {
|
|
|
|
pub pubkey: Pubkey,
|
2022-03-23 00:18:02 -07:00
|
|
|
pub slot: u64,
|
|
|
|
pub write_version: u64,
|
|
|
|
pub lamports: u64,
|
2021-11-01 02:34:25 -07:00
|
|
|
pub owner: Pubkey,
|
|
|
|
pub executable: bool,
|
2022-03-23 00:18:02 -07:00
|
|
|
pub rent_epoch: u64,
|
2021-11-01 02:34:25 -07:00
|
|
|
pub data: Vec<u8>,
|
2022-01-26 01:06:03 -08:00
|
|
|
pub is_selected: bool,
|
2021-11-01 02:34:25 -07:00
|
|
|
}
|
|
|
|
|
2021-11-03 09:22:52 -07:00
|
|
|
impl AccountWrite {
|
2022-03-23 00:18:02 -07:00
|
|
|
fn from(pubkey: Pubkey, slot: u64, write_version: u64, account: Account) -> AccountWrite {
|
2021-11-02 06:35:45 -07:00
|
|
|
AccountWrite {
|
|
|
|
pubkey,
|
2022-03-23 00:18:02 -07:00
|
|
|
slot: slot,
|
2021-11-02 06:35:45 -07:00
|
|
|
write_version,
|
2022-03-23 00:18:02 -07:00
|
|
|
lamports: account.lamports,
|
2021-11-02 06:35:45 -07:00
|
|
|
owner: account.owner,
|
|
|
|
executable: account.executable,
|
2022-03-23 00:18:02 -07:00
|
|
|
rent_epoch: account.rent_epoch,
|
2021-11-15 06:37:29 -08:00
|
|
|
data: account.data,
|
2022-01-26 01:06:03 -08:00
|
|
|
is_selected: true,
|
2021-11-02 06:35:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 03:39:56 -08:00
|
|
|
#[derive(Clone, Debug)]
|
2021-11-01 13:48:17 -07:00
|
|
|
pub struct SlotUpdate {
|
2022-03-23 00:18:02 -07:00
|
|
|
pub slot: u64,
|
|
|
|
pub parent: Option<u64>,
|
|
|
|
pub status: chain_data::SlotStatus,
|
2021-11-01 02:34:25 -07:00
|
|
|
}
|
|
|
|
|
2021-11-08 02:26:01 -08:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct PostgresConfig {
|
|
|
|
pub connection_string: String,
|
2023-02-03 03:39:53 -08:00
|
|
|
/// Number of parallel postgres connections used for insertions
|
|
|
|
pub connection_count: u64,
|
|
|
|
/// Maximum batch size for inserts over one connection
|
|
|
|
pub max_batch_size: usize,
|
|
|
|
/// Max size of queues
|
|
|
|
pub max_queue_size: usize,
|
2021-11-08 02:26:01 -08:00
|
|
|
/// Number of queries retries before fatal error
|
|
|
|
pub retry_query_max_count: u64,
|
|
|
|
/// Seconds to sleep between query retries
|
|
|
|
pub retry_query_sleep_secs: u64,
|
|
|
|
/// Seconds to sleep between connection attempts
|
|
|
|
pub retry_connection_sleep_secs: u64,
|
|
|
|
/// Fatal error when the connection can't be reestablished this long
|
|
|
|
pub fatal_connection_timeout_secs: u64,
|
2021-11-14 04:14:19 -08:00
|
|
|
/// Allow invalid TLS certificates, passed to native_tls danger_accept_invalid_certs
|
|
|
|
pub allow_invalid_certs: bool,
|
2023-02-03 03:39:53 -08:00
|
|
|
pub tls: Option<PostgresTlsConfig>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct PostgresTlsConfig {
|
|
|
|
/// CA Cert file or env var
|
|
|
|
pub ca_cert_path: String,
|
|
|
|
/// PKCS12 client cert path
|
|
|
|
pub client_key_path: String,
|
2021-11-08 02:26:01 -08:00
|
|
|
}
|
|
|
|
|
2021-11-18 05:21:17 -08:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct TlsConfig {
|
|
|
|
pub ca_cert_path: String,
|
|
|
|
pub client_cert_path: String,
|
|
|
|
pub client_key_path: String,
|
2021-11-30 08:15:41 -08:00
|
|
|
pub domain_name: String,
|
2021-11-18 05:21:17 -08:00
|
|
|
}
|
|
|
|
|
2021-11-08 02:42:22 -08:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct GrpcSourceConfig {
|
2021-11-08 11:15:46 -08:00
|
|
|
pub name: String,
|
2021-11-08 02:42:22 -08:00
|
|
|
pub connection_string: String,
|
|
|
|
pub retry_connection_sleep_secs: u64,
|
2021-11-18 05:21:17 -08:00
|
|
|
pub tls: Option<TlsConfig>,
|
2021-11-08 02:42:22 -08:00
|
|
|
}
|
|
|
|
|
2022-03-23 00:51:17 -07:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct SourceConfig {
|
|
|
|
pub dedup_queue_size: usize,
|
|
|
|
pub grpc_sources: Vec<GrpcSourceConfig>,
|
|
|
|
pub snapshot: SnapshotSourceConfig,
|
|
|
|
pub rpc_ws_url: String,
|
|
|
|
}
|
|
|
|
|
2022-12-16 03:00:42 -08:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct FilterConfig {
|
|
|
|
pub program_ids: Vec<String>,
|
2023-01-20 06:52:01 -08:00
|
|
|
pub account_ids: Vec<String>,
|
2022-12-16 03:00:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct StatusResponse<'a> {
|
|
|
|
pub success: bool,
|
|
|
|
pub message: &'a str,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Serialize for StatusResponse<'a> {
|
|
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
|
where
|
|
|
|
S: Serializer,
|
|
|
|
{
|
|
|
|
let mut state = serializer.serialize_struct("Status", 2)?;
|
|
|
|
state.serialize_field("success", &self.success)?;
|
|
|
|
state.serialize_field("message", &self.message)?;
|
|
|
|
|
|
|
|
state.end()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 02:42:22 -08:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct SnapshotSourceConfig {
|
|
|
|
pub rpc_http_url: String,
|
|
|
|
pub program_id: String,
|
|
|
|
}
|
|
|
|
|
2022-10-07 03:44:53 -07:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct MetricsConfig {
|
|
|
|
pub output_stdout: bool,
|
|
|
|
pub output_http: bool,
|
|
|
|
// TODO: add configurable port and endpoint url
|
|
|
|
// TODO: add configurable write interval
|
|
|
|
}
|
|
|
|
|
2021-11-02 05:22:13 -07:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
pub struct Config {
|
2021-11-08 02:26:01 -08:00
|
|
|
pub postgres_target: PostgresConfig,
|
2022-03-23 00:51:17 -07:00
|
|
|
pub source: SourceConfig,
|
2022-10-07 03:44:53 -07:00
|
|
|
pub metrics: MetricsConfig,
|
2021-11-02 05:22:13 -07:00
|
|
|
}
|