mirror of
https://github.com/matter-labs/teepot.git
synced 2025-09-13 20:24:06 +02:00
refactor(verify-era-proof-attestation): replace watch channel with CancellationToken
Refactored stop signal handling in all components to use `tokio_util::sync::CancellationToken` instead of `tokio::sync::watch`. - Improved cancellation logic by leveraging `CancellationToken` for cleaner and more efficient handling. - Updated corresponding dependency to `tokio-util` version `0.7.14`.
This commit is contained in:
parent
2605e2ae3a
commit
95b6a2d70a
9 changed files with 45 additions and 52 deletions
|
@ -8,7 +8,7 @@ use crate::{
|
|||
proof::Proof,
|
||||
verification::{AttestationVerifier, PolicyEnforcer, SignatureVerifier, VerificationReporter},
|
||||
};
|
||||
use tokio::sync::watch;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use zksync_basic_types::L1BatchNumber;
|
||||
|
||||
/// Result of a batch verification
|
||||
|
@ -40,7 +40,7 @@ impl<C: JsonRpcClient> BatchVerifier<C> {
|
|||
/// Verify proofs for a batch
|
||||
pub async fn verify_batch_proofs(
|
||||
&self,
|
||||
stop_receiver: &mut watch::Receiver<bool>,
|
||||
token: &CancellationToken,
|
||||
batch_number: L1BatchNumber,
|
||||
proofs: Vec<Proof>,
|
||||
) -> error::Result<BatchVerificationResult> {
|
||||
|
@ -49,7 +49,7 @@ impl<C: JsonRpcClient> BatchVerifier<C> {
|
|||
let mut verified_proofs_count: u32 = 0;
|
||||
|
||||
for proof in proofs.into_iter() {
|
||||
if *stop_receiver.borrow() {
|
||||
if token.is_cancelled() {
|
||||
tracing::warn!("Stop signal received during batch verification");
|
||||
return Ok(BatchVerificationResult {
|
||||
total_count: total_proofs_count,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue