v0.3.12-pre.003-fix.001
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
// file: crates/ksp-worker-raw-transaction-ingest-lib/src/runtime_resources.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
#[cfg(test)]
|
||||
use sha2::Digest; // rust-rules: trait-import
|
||||
|
||||
#[cfg(test)]
|
||||
const RAW_TRANSACTION_INGEST_YELLOWSTONE_FILTER_FINGERPRINT_DOMAIN: &[u8] = b"ksp.raw_transaction_ingest.yellowstone.filters.v1\0";
|
||||
|
||||
#[cfg(test)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
enum RawTransactionIngestSourceFamily {
|
||||
Transaction,
|
||||
@@ -17,18 +20,21 @@ struct RawTransactionIngestSourceRoute {
|
||||
provider: ksp_store_lib::RawProvenanceCode,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
struct RawTransactionIngestSourceTimestamp {
|
||||
nanos: u32,
|
||||
seconds: i64,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl std::fmt::Debug for RawTransactionIngestSourceTimestamp {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return formatter.debug_struct("RawTransactionIngestSourceTimestamp").field("nanos", &self.nanos).field("seconds", &self.seconds).finish();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
struct RawTransactionIngestSourceSignal {
|
||||
created_at: std::option::Option<RawTransactionIngestSourceTimestamp>,
|
||||
@@ -42,6 +48,7 @@ struct RawTransactionIngestSourceSignal {
|
||||
transaction_index: std::option::Option<u64>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl std::fmt::Debug for RawTransactionIngestSourceSignal {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return formatter
|
||||
@@ -59,6 +66,7 @@ impl std::fmt::Debug for RawTransactionIngestSourceSignal {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
trait RawTransactionIngestYellowstoneSignalView {
|
||||
fn created_at(&self) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneUpdateTimestamp>;
|
||||
|
||||
@@ -73,6 +81,7 @@ trait RawTransactionIngestYellowstoneSignalView {
|
||||
fn slot(&self) -> u64;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl RawTransactionIngestYellowstoneSignalView for ksp_onchain_transport_lib::YellowstoneTransactionUpdate {
|
||||
fn created_at(&self) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneUpdateTimestamp> {
|
||||
return ksp_onchain_transport_lib::YellowstoneTransactionUpdate::created_at(self);
|
||||
@@ -99,6 +108,7 @@ impl RawTransactionIngestYellowstoneSignalView for ksp_onchain_transport_lib::Ye
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl RawTransactionIngestYellowstoneSignalView for ksp_onchain_transport_lib::YellowstoneTransactionStatusUpdate {
|
||||
fn created_at(&self) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneUpdateTimestamp> {
|
||||
return ksp_onchain_transport_lib::YellowstoneTransactionStatusUpdate::created_at(self);
|
||||
@@ -125,6 +135,7 @@ impl RawTransactionIngestYellowstoneSignalView for ksp_onchain_transport_lib::Ye
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl std::convert::From<(&crate::RawTransactionIngestYellowstoneSource, &ksp_onchain_transport_lib::YellowstoneTransactionUpdate)>
|
||||
for RawTransactionIngestSourceSignal
|
||||
{
|
||||
@@ -133,6 +144,7 @@ impl std::convert::From<(&crate::RawTransactionIngestYellowstoneSource, &ksp_onc
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl std::convert::From<(&crate::RawTransactionIngestYellowstoneSource, &ksp_onchain_transport_lib::YellowstoneTransactionStatusUpdate)>
|
||||
for RawTransactionIngestSourceSignal
|
||||
{
|
||||
@@ -212,6 +224,7 @@ impl std::fmt::Debug for crate::RawTransactionIngestYellowstoneSource {
|
||||
.field("yellowstone_endpoint_name", &self.yellowstone_channel.endpoint_name())
|
||||
.field("yellowstone_provider", &self.yellowstone_channel.provider().as_str())
|
||||
.field("network", &self.network.as_str())
|
||||
.field("route", &self.route)
|
||||
.field("transaction_filter_count", &self.subscribe_request.transaction_filter_count())
|
||||
.field("transaction_status_filter_count", &self.subscribe_request.transaction_status_filter_count())
|
||||
.field("block_filter_count", &self.subscribe_request.block_filter_count())
|
||||
@@ -286,6 +299,7 @@ fn ingestion_filter_count(request: &ksp_onchain_transport_lib::YellowstoneSubscr
|
||||
return request.transaction_filter_count().saturating_add(request.transaction_status_filter_count()).saturating_add(request.block_filter_count());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn matched_filter_fingerprint(filters: &[ksp_onchain_transport_lib::YellowstoneSubscribeFilterName]) -> [u8; 32] {
|
||||
let mut names = filters.iter().map(ksp_onchain_transport_lib::YellowstoneSubscribeFilterName::as_str).collect::<std::vec::Vec<_>>();
|
||||
names.sort_unstable();
|
||||
@@ -300,6 +314,7 @@ fn matched_filter_fingerprint(filters: &[ksp_onchain_transport_lib::YellowstoneS
|
||||
return hasher.finalize().into();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn project_yellowstone_signal<T: RawTransactionIngestYellowstoneSignalView>(
|
||||
source: &crate::RawTransactionIngestYellowstoneSource,
|
||||
update: &T,
|
||||
|
||||
Reference in New Issue
Block a user