Skip to content

Commit 63558cc

Browse files
nits
1 parent bea1cb4 commit 63558cc

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

chain/src/indexer/backfiller/consumer.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ enum Completion {
2525
height: u64,
2626
digest: Digest,
2727
},
28-
/// The queue entry became redundant because the live certificate path
28+
/// The queue entry was skipped because the live certificate path
2929
/// uploaded the block first.
30-
Retired { position: u64, height: u64 },
30+
Skipped { position: u64, height: u64 },
3131
}
3232

3333
pub struct Consumer<E: Spawner + Clock + Storage + Metrics, C: Client> {
@@ -146,11 +146,8 @@ impl<E: Spawner + Clock + Storage + Metrics, C: Client> Consumer<E, C> {
146146

147147
async fn start_upload(&mut self, position: u64, entry: Entry) {
148148
let Entry { height, digest } = entry;
149-
if matches!(
150-
self.uploads.lock().upload_decision(&digest),
151-
Decision::Retire
152-
) {
153-
self.complete(Completion::Retired { position, height })
149+
if matches!(self.uploads.lock().should_upload(&digest), Decision::Skip) {
150+
self.complete(Completion::Skipped { position, height })
154151
.await;
155152
debug!(?digest, "consumer skipping already-uploaded block");
156153
return;
@@ -171,20 +168,20 @@ impl<E: Spawner + Clock + Storage + Metrics, C: Client> Consumer<E, C> {
171168
.await
172169
else {
173170
debug!(?digest, "consumer observed live upload before block upload");
174-
return Completion::Retired { position, height };
171+
return Completion::Skipped { position, height };
175172
};
176173

177174
loop {
178175
// A live notarization/finalization upload may complete while this
179176
// queue item is waiting for its block or retrying after failures.
180177
let decision = {
181178
let uploads = uploads.lock();
182-
uploads.upload_decision(&digest)
179+
uploads.should_upload(&digest)
183180
};
184181
match decision {
185-
Decision::Retire => {
182+
Decision::Skip => {
186183
debug!(?digest, "consumer observed live upload before block upload");
187-
return Completion::Retired { position, height };
184+
return Completion::Skipped { position, height };
188185
}
189186
Decision::Wait => {
190187
context.sleep(retry).await;
@@ -238,8 +235,8 @@ impl<E: Spawner + Clock + Storage + Metrics, C: Client> Consumer<E, C> {
238235
loop {
239236
let next = {
240237
let uploads = uploads.lock();
241-
match uploads.upload_decision(&digest) {
242-
Decision::Retire => NextBlock::AlreadyUploaded,
238+
match uploads.should_upload(&digest) {
239+
Decision::Skip => NextBlock::AlreadyUploaded,
243240
Decision::Wait => NextBlock::WaitForCertificate,
244241
Decision::Proceed => {
245242
if let Some(block) = uploads.cached_block(&digest) {
@@ -284,7 +281,7 @@ impl<E: Spawner + Clock + Storage + Metrics, C: Client> Consumer<E, C> {
284281
self.uploads.lock().mark_uploaded(digest, height);
285282
(position, height)
286283
}
287-
Completion::Retired { position, height } => (position, height),
284+
Completion::Skipped { position, height } => (position, height),
288285
};
289286

290287
let floor = self.reader.ack_floor().await;

chain/src/indexer/backfiller/state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::{collections::BTreeMap, sync::Arc};
77

88
/// What the backfiller should do next for a digest.
99
pub enum Decision {
10-
/// The block is already uploaded, so the queue entry can be retired.
11-
Retire,
10+
/// The block is already uploaded, so the queue entry can be skipped.
11+
Skip,
1212
/// The live certificate path is still handling this digest, so the backfiller
1313
/// should wait instead of racing it.
1414
Wait,
@@ -117,9 +117,9 @@ impl State {
117117
self.cached_blocks.get(digest).cloned()
118118
}
119119

120-
pub fn upload_decision(&self, digest: &Digest) -> Decision {
120+
pub fn should_upload(&self, digest: &Digest) -> Decision {
121121
if self.is_uploaded(digest) {
122-
Decision::Retire
122+
Decision::Skip
123123
} else if self.certificate_uploads.contains_key(digest) {
124124
Decision::Wait
125125
} else {

0 commit comments

Comments
 (0)