0.7.24-pre.1
This commit is contained in:
@@ -31,6 +31,8 @@ pub struct KbTokenBackfillResult {
|
||||
pub wallet_participation_count: usize,
|
||||
/// Total number of trade-aggregation results produced during this run.
|
||||
pub trade_event_count: usize,
|
||||
/// Total number of pair-candle aggregation results produced during this run.
|
||||
pub pair_candle_count: usize,
|
||||
}
|
||||
|
||||
/// One pool-backfill result summary.
|
||||
@@ -58,6 +60,8 @@ pub struct KbPoolBackfillResult {
|
||||
pub wallet_participation_count: usize,
|
||||
/// Total number of trade-aggregation results produced during this run.
|
||||
pub trade_event_count: usize,
|
||||
/// Total number of pair-candle aggregation results produced during this run.
|
||||
pub pair_candle_count: usize,
|
||||
}
|
||||
|
||||
/// Historical token backfill service.
|
||||
@@ -77,6 +81,7 @@ pub struct KbTokenBackfillService {
|
||||
pool_origin_service: crate::KbPoolOriginService,
|
||||
wallet_observation_service: crate::KbWalletObservationService,
|
||||
trade_aggregation_service: crate::KbTradeAggregationService,
|
||||
pair_candle_aggregation_service: crate::KbPairCandleAggregationService,
|
||||
}
|
||||
|
||||
impl KbTokenBackfillService {
|
||||
@@ -94,6 +99,8 @@ impl KbTokenBackfillService {
|
||||
let pool_origin_service = crate::KbPoolOriginService::new(database.clone());
|
||||
let wallet_observation_service = crate::KbWalletObservationService::new(database.clone());
|
||||
let trade_aggregation_service = crate::KbTradeAggregationService::new(database.clone());
|
||||
let pair_candle_aggregation_service =
|
||||
crate::KbPairCandleAggregationService::new(database.clone());
|
||||
Self {
|
||||
http_pool,
|
||||
database,
|
||||
@@ -106,6 +113,7 @@ impl KbTokenBackfillService {
|
||||
pool_origin_service,
|
||||
wallet_observation_service,
|
||||
trade_aggregation_service,
|
||||
pair_candle_aggregation_service,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +138,7 @@ impl KbTokenBackfillService {
|
||||
pool_origin_count: 0,
|
||||
wallet_participation_count: 0,
|
||||
trade_event_count: 0,
|
||||
pair_candle_count: 0,
|
||||
};
|
||||
let mut seen_signatures = std::collections::HashSet::<std::string::String>::new();
|
||||
let mint_signatures_result = self
|
||||
@@ -199,7 +208,8 @@ impl KbTokenBackfillService {
|
||||
"launchAttributionCount": result.launch_attribution_count,
|
||||
"poolOriginCount": result.pool_origin_count,
|
||||
"walletParticipationCount": result.wallet_participation_count,
|
||||
"tradeEventCount": result.trade_event_count
|
||||
"tradeEventCount": result.trade_event_count,
|
||||
"pairCandleCount": result.pair_candle_count
|
||||
});
|
||||
let observation_result = self
|
||||
.persistence
|
||||
@@ -335,6 +345,7 @@ impl KbTokenBackfillService {
|
||||
pool_origin_count: 0,
|
||||
wallet_participation_count: 0,
|
||||
trade_event_count: 0,
|
||||
pair_candle_count: 0,
|
||||
});
|
||||
}
|
||||
let existing_transaction_result =
|
||||
@@ -405,6 +416,14 @@ impl KbTokenBackfillService {
|
||||
Ok(trade_aggregations) => trade_aggregations,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let pair_candle_aggregations_result = self
|
||||
.pair_candle_aggregation_service
|
||||
.record_transaction_by_signature(signature.as_str())
|
||||
.await;
|
||||
let pair_candle_aggregations = match pair_candle_aggregations_result {
|
||||
Ok(pair_candle_aggregations) => pair_candle_aggregations,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
Ok(KbTokenBackfillSignatureResult {
|
||||
resolved_transaction_count: 1,
|
||||
missing_transaction_count: 0,
|
||||
@@ -414,6 +433,7 @@ impl KbTokenBackfillService {
|
||||
pool_origin_count: pool_origins.len(),
|
||||
wallet_participation_count: wallet_observations.len(),
|
||||
trade_event_count: trade_aggregations.len(),
|
||||
pair_candle_count: pair_candle_aggregations.len(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -440,6 +460,7 @@ impl KbTokenBackfillService {
|
||||
pool_origin_count: 0,
|
||||
wallet_participation_count: 0,
|
||||
trade_event_count: 0,
|
||||
pair_candle_count: 0,
|
||||
};
|
||||
let mut seen_addresses = std::collections::BTreeSet::<std::string::String>::new();
|
||||
let mut addresses_to_scan = std::vec::Vec::<std::string::String>::new();
|
||||
@@ -522,6 +543,7 @@ impl KbTokenBackfillService {
|
||||
result.pool_origin_count += replay_result.pool_origin_count;
|
||||
result.wallet_participation_count += replay_result.wallet_participation_count;
|
||||
result.trade_event_count += replay_result.trade_event_count;
|
||||
result.pair_candle_count += replay_result.pair_candle_count;
|
||||
}
|
||||
}
|
||||
let summary_payload = serde_json::json!({
|
||||
@@ -536,6 +558,7 @@ impl KbTokenBackfillService {
|
||||
"poolOriginCount": result.pool_origin_count,
|
||||
"walletParticipationCount": result.wallet_participation_count,
|
||||
"tradeEventCount": result.trade_event_count,
|
||||
"pairCandleCount": result.pair_candle_count,
|
||||
"scannedAddressCount": addresses_to_scan.len(),
|
||||
"effectiveSignatureLimit": effective_limit
|
||||
});
|
||||
@@ -582,6 +605,7 @@ struct KbTokenBackfillSignatureResult {
|
||||
pool_origin_count: usize,
|
||||
wallet_participation_count: usize,
|
||||
trade_event_count: usize,
|
||||
pair_candle_count: usize,
|
||||
}
|
||||
|
||||
fn kb_merge_token_backfill_signature_result(
|
||||
@@ -596,6 +620,7 @@ fn kb_merge_token_backfill_signature_result(
|
||||
aggregate.pool_origin_count += value.pool_origin_count;
|
||||
aggregate.wallet_participation_count += value.wallet_participation_count;
|
||||
aggregate.trade_event_count += value.trade_event_count;
|
||||
aggregate.pair_candle_count += value.pair_candle_count;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -948,6 +973,7 @@ mod tests {
|
||||
assert_eq!(backfill.resolved_transaction_count, 2);
|
||||
assert_eq!(backfill.missing_transaction_count, 0);
|
||||
assert_eq!(backfill.trade_event_count, 1);
|
||||
assert!(backfill.pair_candle_count > 0);
|
||||
let token_result = crate::get_token_by_mint(database.as_ref(), "BackfillToken111").await;
|
||||
let token_option = match token_result {
|
||||
Ok(token_option) => token_option,
|
||||
@@ -1004,6 +1030,15 @@ mod tests {
|
||||
};
|
||||
assert_eq!(pair_metric.trade_count, 1);
|
||||
assert_eq!(pair_metric.buy_count, 1);
|
||||
let candles_result =
|
||||
crate::list_pair_candles_by_pair_and_timeframe(database.as_ref(), pair_id, 60).await;
|
||||
let candles = match candles_result {
|
||||
Ok(candles) => candles,
|
||||
Err(error) => panic!("pair candle list must succeed: {}", error),
|
||||
};
|
||||
assert_eq!(candles.len(), 1);
|
||||
assert_eq!(candles[0].trade_count, 1);
|
||||
assert_eq!(candles[0].close_price_quote_per_base, 2.5);
|
||||
server.shutdown().await;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user