0.7.25
This commit is contained in:
@@ -38,11 +38,11 @@ impl KbWsTransactionResolutionEnvelope {
|
||||
notification: crate::KbJsonRpcWsNotification,
|
||||
subscription: std::option::Option<crate::WsSubscriptionInfo>,
|
||||
) -> Self {
|
||||
Self {
|
||||
return Self {
|
||||
endpoint_name,
|
||||
notification,
|
||||
subscription,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ impl KbTransactionResolutionService {
|
||||
crate::KbPairCandleAggregationService::new(database.clone());
|
||||
let pair_analytic_signal_service =
|
||||
crate::KbPairAnalyticSignalService::new(database.clone());
|
||||
Self {
|
||||
return Self {
|
||||
http_pool,
|
||||
persistence,
|
||||
http_role,
|
||||
@@ -151,12 +151,12 @@ impl KbTransactionResolutionService {
|
||||
resolved_signatures: std::sync::Arc::new(tokio::sync::Mutex::new(
|
||||
std::collections::HashSet::new(),
|
||||
)),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Returns the persistence façade used by the resolver.
|
||||
pub fn persistence(&self) -> &crate::KbDetectionPersistenceService {
|
||||
&self.persistence
|
||||
return &self.persistence;
|
||||
}
|
||||
|
||||
/// Builds one transaction resolution request from one WS envelope.
|
||||
@@ -178,7 +178,7 @@ impl KbTransactionResolutionService {
|
||||
None => return None,
|
||||
};
|
||||
let slot_hint = kb_extract_resolution_slot(&envelope.notification);
|
||||
Some(crate::KbTransactionResolutionRequest {
|
||||
return Some(crate::KbTransactionResolutionRequest {
|
||||
signature,
|
||||
trigger_method: envelope.notification.method.clone(),
|
||||
source_endpoint_name: envelope.endpoint_name.clone(),
|
||||
@@ -189,7 +189,7 @@ impl KbTransactionResolutionService {
|
||||
"subscription": envelope.notification.params.subscription,
|
||||
"result": envelope.notification.params.result,
|
||||
}),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/// Processes one forwarded WS envelope.
|
||||
@@ -221,21 +221,21 @@ impl KbTransactionResolutionService {
|
||||
signature: request.signature.clone(),
|
||||
signal_id,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
match &outcome {
|
||||
crate::KbTransactionResolutionOutcome::Resolved { signature, .. } => {
|
||||
let mut resolved_guard = self.resolved_signatures.lock().await;
|
||||
resolved_guard.insert(signature.clone());
|
||||
}
|
||||
},
|
||||
crate::KbTransactionResolutionOutcome::Missing { signature, .. } => {
|
||||
let mut resolved_guard = self.resolved_signatures.lock().await;
|
||||
resolved_guard.insert(signature.clone());
|
||||
}
|
||||
crate::KbTransactionResolutionOutcome::Ignored => {}
|
||||
crate::KbTransactionResolutionOutcome::ErrorSignaled { .. } => {}
|
||||
},
|
||||
crate::KbTransactionResolutionOutcome::Ignored => {},
|
||||
crate::KbTransactionResolutionOutcome::ErrorSignaled { .. } => {},
|
||||
}
|
||||
Ok(outcome)
|
||||
return Ok(outcome);
|
||||
}
|
||||
|
||||
async fn resolve_request(
|
||||
@@ -450,11 +450,11 @@ impl KbTransactionResolutionService {
|
||||
Ok(signal_id) => signal_id,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
Ok(crate::KbTransactionResolutionOutcome::Resolved {
|
||||
return Ok(crate::KbTransactionResolutionOutcome::Resolved {
|
||||
signature: request.signature.clone(),
|
||||
observation_id,
|
||||
signal_id,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
async fn record_resolution_error_signal(
|
||||
@@ -471,7 +471,8 @@ impl KbTransactionResolutionService {
|
||||
"triggerPayload": request.trigger_payload.clone(),
|
||||
"error": error.to_string()
|
||||
});
|
||||
self.persistence
|
||||
return self
|
||||
.persistence
|
||||
.record_signal(&crate::KbDetectionSignalInput::new(
|
||||
"signal.transaction_resolution.error".to_string(),
|
||||
crate::KbAnalysisSignalSeverity::High,
|
||||
@@ -480,7 +481,7 @@ impl KbTransactionResolutionService {
|
||||
None,
|
||||
payload,
|
||||
))
|
||||
.await
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +495,7 @@ pub struct KbWsTransactionResolutionRelay {
|
||||
impl KbWsTransactionResolutionRelay {
|
||||
/// Creates a new transaction resolution relay.
|
||||
pub fn new(resolver: crate::KbTransactionResolutionService) -> Self {
|
||||
Self { resolver }
|
||||
return Self { resolver };
|
||||
}
|
||||
|
||||
/// Creates a bounded relay channel.
|
||||
@@ -504,7 +505,7 @@ impl KbWsTransactionResolutionRelay {
|
||||
tokio::sync::mpsc::Sender<crate::KbWsTransactionResolutionEnvelope>,
|
||||
tokio::sync::mpsc::Receiver<crate::KbWsTransactionResolutionEnvelope>,
|
||||
) {
|
||||
tokio::sync::mpsc::channel(capacity)
|
||||
return tokio::sync::mpsc::channel(capacity);
|
||||
}
|
||||
|
||||
/// Processes one forwarded envelope.
|
||||
@@ -512,7 +513,7 @@ impl KbWsTransactionResolutionRelay {
|
||||
&self,
|
||||
envelope: &crate::KbWsTransactionResolutionEnvelope,
|
||||
) -> Result<crate::KbTransactionResolutionOutcome, crate::KbError> {
|
||||
self.resolver.process_ws_envelope(envelope).await
|
||||
return self.resolver.process_ws_envelope(envelope).await;
|
||||
}
|
||||
|
||||
/// Spawns one background relay worker.
|
||||
@@ -520,7 +521,7 @@ impl KbWsTransactionResolutionRelay {
|
||||
self,
|
||||
mut receiver: tokio::sync::mpsc::Receiver<crate::KbWsTransactionResolutionEnvelope>,
|
||||
) -> tokio::task::JoinHandle<crate::KbWsTransactionResolutionRelayStats> {
|
||||
tokio::spawn(async move {
|
||||
return tokio::spawn(async move {
|
||||
let mut stats = crate::KbWsTransactionResolutionRelayStats::default();
|
||||
loop {
|
||||
let recv_result = receiver.recv().await;
|
||||
@@ -541,25 +542,25 @@ impl KbWsTransactionResolutionRelay {
|
||||
error
|
||||
);
|
||||
continue;
|
||||
}
|
||||
},
|
||||
};
|
||||
match outcome {
|
||||
crate::KbTransactionResolutionOutcome::Ignored => {
|
||||
stats.ignored_count += 1;
|
||||
}
|
||||
},
|
||||
crate::KbTransactionResolutionOutcome::Resolved { .. } => {
|
||||
stats.resolved_count += 1;
|
||||
}
|
||||
},
|
||||
crate::KbTransactionResolutionOutcome::Missing { .. } => {
|
||||
stats.missing_count += 1;
|
||||
}
|
||||
},
|
||||
crate::KbTransactionResolutionOutcome::ErrorSignaled { .. } => {
|
||||
stats.error_count += 1;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
stats
|
||||
})
|
||||
return stats;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,7 +586,7 @@ fn kb_extract_resolution_signature(
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
return None;
|
||||
}
|
||||
|
||||
fn kb_extract_resolution_slot(
|
||||
@@ -605,5 +606,5 @@ fn kb_extract_resolution_slot(
|
||||
return Some(slot);
|
||||
}
|
||||
}
|
||||
None
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user