Skip to content

Commit 6ed0584

Browse files
committed
Store PayloadStatus within WithStatus struct.
1 parent 2d7698d commit 6ed0584

File tree

6 files changed

+85
-79
lines changed

6 files changed

+85
-79
lines changed

fork_choice_control/src/helpers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ impl<P: Preset> Context<P> {
505505
.check_block_root(block.message().hash_tree_root())
506506
.expect("no storage errors should occur")
507507
.expect("block should be present in the store")
508-
.optimistic,
508+
.status
509+
.is_optimistic(),
509510
expected_optimistic,
510511
);
511512
}

fork_choice_control/src/queries.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ where
111111

112112
Ok(WithStatus {
113113
value: chain_link.state(&store),
114-
optimistic: chain_link.is_optimistic(),
114+
status: chain_link.payload_status,
115115
finalized: store.is_slot_finalized(chain_link.slot()),
116116
})
117117
}
@@ -123,7 +123,7 @@ where
123123

124124
WithStatus {
125125
value: chain_link.block_root,
126-
optimistic: chain_link.is_optimistic(),
126+
status: chain_link.payload_status,
127127
finalized: true,
128128
}
129129
}
@@ -135,7 +135,7 @@ where
135135

136136
WithStatus {
137137
value: chain_link.block.clone_arc(),
138-
optimistic: chain_link.is_optimistic(),
138+
status: chain_link.payload_status,
139139
finalized: true,
140140
}
141141
}
@@ -153,7 +153,7 @@ where
153153

154154
WithStatus {
155155
value: chain_link.state(&store),
156-
optimistic: chain_link.is_optimistic(),
156+
status: chain_link.payload_status,
157157
finalized: true,
158158
}
159159
}
@@ -226,7 +226,7 @@ where
226226

227227
WithStatus {
228228
value: head.clone(),
229-
optimistic: head.is_optimistic(),
229+
status: head.payload_status,
230230
finalized: store.is_slot_finalized(head.slot()),
231231
}
232232
}
@@ -243,7 +243,7 @@ where
243243

244244
WithStatus {
245245
value: head.block_root,
246-
optimistic: head.is_optimistic(),
246+
status: head.payload_status,
247247
finalized: store.is_slot_finalized(head.slot()),
248248
}
249249
}
@@ -255,7 +255,7 @@ where
255255

256256
WithStatus {
257257
value: head.block.clone_arc(),
258-
optimistic: head.is_optimistic(),
258+
status: head.payload_status,
259259
finalized: store.is_slot_finalized(head.slot()),
260260
}
261261
}
@@ -267,7 +267,7 @@ where
267267

268268
WithStatus {
269269
value: head.state(&store),
270-
optimistic: head.is_optimistic(),
270+
status: head.payload_status,
271271
finalized: store.is_slot_finalized(head.slot()),
272272
}
273273
}
@@ -343,7 +343,7 @@ where
343343
if let Some(chain_link) = store.chain_link(block_root) {
344344
return Ok(Some(WithStatus {
345345
value: block_root,
346-
optimistic: chain_link.is_optimistic(),
346+
status: chain_link.payload_status,
347347
finalized: store.is_slot_finalized(chain_link.slot()),
348348
}));
349349
}
@@ -388,7 +388,7 @@ where
388388

389389
return Ok(Some(WithStatus {
390390
value: BlockWithRoot { block, root },
391-
optimistic: chain_link.is_optimistic(),
391+
status: chain_link.payload_status,
392392
finalized: store.is_slot_finalized(chain_link.slot()),
393393
}));
394394
}
@@ -541,7 +541,7 @@ where
541541

542542
Ok(WithStatus {
543543
value: state,
544-
optimistic: head.is_optimistic(),
544+
status: head.payload_status,
545545
finalized: store.is_slot_finalized(head.slot()),
546546
})
547547
}
@@ -874,7 +874,7 @@ impl<P: Preset> Snapshot<'_, P> {
874874

875875
return Ok(Some(WithStatus {
876876
value: state,
877-
optimistic: chain_link.is_optimistic(),
877+
status: chain_link.payload_status,
878878
finalized: store.is_slot_finalized(slot),
879879
}));
880880
}

fork_choice_store/src/store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ impl<P: Preset> Store<P> {
418418

419419
Some(WithStatus {
420420
value: &chain_link.block,
421-
optimistic: chain_link.is_optimistic(),
421+
status: chain_link.payload_status,
422422
finalized: self.is_slot_finalized(chain_link.slot()),
423423
})
424424
}
@@ -471,7 +471,7 @@ impl<P: Preset> Store<P> {
471471
.find(|chain_link| chain_link.block.message().state_root() == state_root)
472472
.map(|chain_link| WithStatus {
473473
value: chain_link.state(self),
474-
optimistic: chain_link.is_optimistic(),
474+
status: chain_link.payload_status,
475475
finalized: self.is_slot_finalized(chain_link.slot()),
476476
})
477477
}

0 commit comments

Comments
 (0)