v0.3.6-pre.008
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-job-backfill-lib/src/discovery.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
/// Network-scoped identity of one discovered transaction candidate before canonical signature decoding.
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
@@ -100,6 +100,17 @@ pub struct BackfillDiscovery {
|
||||
}
|
||||
|
||||
impl BackfillDiscovery {
|
||||
/// Creates one internally validated bounded discovery value.
|
||||
pub(crate) fn new(
|
||||
network: ksp_store_lib::RawNetworkId,
|
||||
scope_fingerprint: crate::BackfillScopeFingerprint,
|
||||
candidates: std::vec::Vec<BackfillCandidate>,
|
||||
pages_fetched: usize,
|
||||
boundary: BackfillDiscoveryBoundary,
|
||||
) -> Self {
|
||||
return Self { network, scope_fingerprint, candidates, pages_fetched, boundary };
|
||||
}
|
||||
|
||||
/// Returns the logical network shared by every candidate identity.
|
||||
#[must_use]
|
||||
pub const fn network(&self) -> &ksp_store_lib::RawNetworkId {
|
||||
@@ -244,13 +255,13 @@ fn discover_explicit(request: &crate::BackfillRequest) -> ksp_core_lib::Result<B
|
||||
let identity = BackfillCandidateIdentity::new(request.network().clone(), signature.clone());
|
||||
candidates.push(BackfillCandidate::new(identity, std::option::Option::None));
|
||||
}
|
||||
return std::result::Result::Ok(BackfillDiscovery {
|
||||
network: request.network().clone(),
|
||||
scope_fingerprint: request.scope_fingerprint(),
|
||||
return std::result::Result::Ok(BackfillDiscovery::new(
|
||||
request.network().clone(),
|
||||
request.scope_fingerprint(),
|
||||
candidates,
|
||||
pages_fetched: 0,
|
||||
boundary: BackfillDiscoveryBoundary::ExplicitInput,
|
||||
});
|
||||
0,
|
||||
BackfillDiscoveryBoundary::ExplicitInput,
|
||||
));
|
||||
}
|
||||
|
||||
async fn discover_older<S>(source: &S, request: &crate::BackfillRequest) -> ksp_core_lib::Result<BackfillDiscovery>
|
||||
@@ -262,7 +273,7 @@ where
|
||||
std::option::Option::None => return std::result::Result::Err(discovery_invalid("scope.address")),
|
||||
};
|
||||
let mut before = match request.scope().kind() {
|
||||
crate::BackfillScopeKind::BeforeAddress => request.scope().anchor().map(|value| return value.as_str().to_owned()),
|
||||
crate::BackfillScopeKind::BeforeAddress => crate::resume_before_cursor(request),
|
||||
crate::BackfillScopeKind::LatestAddress => std::option::Option::None,
|
||||
crate::BackfillScopeKind::AfterAddress | crate::BackfillScopeKind::ExplicitSignatures => {
|
||||
return std::result::Result::Err(discovery_invalid("scope.kind"));
|
||||
@@ -333,13 +344,7 @@ where
|
||||
}
|
||||
before = std::option::Option::Some(next_before.as_str().to_owned());
|
||||
};
|
||||
return std::result::Result::Ok(BackfillDiscovery {
|
||||
network: request.network().clone(),
|
||||
scope_fingerprint: request.scope_fingerprint(),
|
||||
candidates,
|
||||
pages_fetched,
|
||||
boundary,
|
||||
});
|
||||
return std::result::Result::Ok(BackfillDiscovery::new(request.network().clone(), request.scope_fingerprint(), candidates, pages_fetched, boundary));
|
||||
}
|
||||
|
||||
async fn discover_after<S>(source: &S, request: &crate::BackfillRequest) -> ksp_core_lib::Result<BackfillDiscovery>
|
||||
@@ -416,13 +421,13 @@ where
|
||||
}
|
||||
before = std::option::Option::Some(next_before.as_str().to_owned());
|
||||
};
|
||||
return std::result::Result::Ok(BackfillDiscovery {
|
||||
network: request.network().clone(),
|
||||
scope_fingerprint: request.scope_fingerprint(),
|
||||
candidates: nearest.into_iter().collect(),
|
||||
return std::result::Result::Ok(BackfillDiscovery::new(
|
||||
request.network().clone(),
|
||||
request.scope_fingerprint(),
|
||||
nearest.into_iter().collect(),
|
||||
pages_fetched,
|
||||
boundary,
|
||||
});
|
||||
));
|
||||
}
|
||||
|
||||
fn validated_signature(value: &str) -> ksp_core_lib::Result<crate::BackfillSignature> {
|
||||
|
||||
Reference in New Issue
Block a user