File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -648,6 +648,9 @@ where
648
648
match ( curr_orig. as_ref ( ) , curr_update. as_ref ( ) ) {
649
649
// Update block that doesn't exist in the original chain
650
650
( o, Some ( u) ) if Some ( u. height ( ) ) > o. map ( |o| o. height ( ) ) => {
651
+ // Only append to `ChangeSet` when the update has complete data. Entries where
652
+ // `data` does not exist that are created via `prev_blockhash` should not alter the
653
+ // `ChangeSet`.
651
654
if let Some ( data) = u. data ( ) {
652
655
changeset. blocks . insert ( u. height ( ) , Some ( data) ) ;
653
656
}
Original file line number Diff line number Diff line change @@ -217,6 +217,11 @@ where
217
217
{
218
218
/// Construct a new base [`CheckPoint`] from given `height` and `data` at the front of a linked
219
219
/// list.
220
+ ///
221
+ /// If `data` contains previous block via [`ToBlockHash::prev_blockhash`], this will also create
222
+ /// a placeholder checkpoint at `height - 1` with that hash and with `data: None`, and link the
223
+ /// new checkpoint to it. The placeholder can be materialized later by inserting data at its
224
+ /// height.
220
225
pub fn new ( height : u32 , data : D ) -> Self {
221
226
// If `data` has a `prev_blockhash`, create a placeholder checkpoint one height below.
222
227
let prev = if height > 0 {
@@ -276,8 +281,10 @@ where
276
281
/// The effect of `insert` depends on whether a height already exists. If it doesn't, the data
277
282
/// we inserted and all pre-existing entries higher than it will be re-inserted after it. If the
278
283
/// height already existed and has a conflicting block hash then it will be purged along with
279
- /// all entries following it. The returned chain will have a tip of the data passed in. Of
280
- /// course, if the data was already present then this just returns `self`.
284
+ /// all entries following it. If the existing checkpoint at height is a placeholder where
285
+ /// `data: None` with the same hash, then the `data` is inserted to make a complete checkpoint.
286
+ /// The returned chain will have a tip of the data passed in. If the data was already present
287
+ /// then this just returns `self`. This method does not create new placeholders.
281
288
///
282
289
/// # Panics
283
290
///
You can’t perform that action at this time.
0 commit comments