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
648648 match ( curr_orig. as_ref ( ) , curr_update. as_ref ( ) ) {
649649 // Update block that doesn't exist in the original chain
650650 ( 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`.
651654 if let Some ( data) = u. data ( ) {
652655 changeset. blocks . insert ( u. height ( ) , Some ( data) ) ;
653656 }
Original file line number Diff line number Diff line change @@ -213,6 +213,11 @@ where
213213{
214214 /// Construct a new base [`CheckPoint`] from given `height` and `data` at the front of a linked
215215 /// list.
216+ ///
217+ /// If `data` contains previous block via [`ToBlockHash::prev_blockhash`], this will also create
218+ /// a placeholder checkpoint at `height - 1` with that hash and with `data: None`, and link the
219+ /// new checkpoint to it. The placeholder can be materialized later by inserting data at its
220+ /// height.
216221 pub fn new ( height : u32 , data : D ) -> Self {
217222 // If `data` has a `prev_blockhash`, create a placeholder checkpoint one height below.
218223 let prev = if height > 0 {
@@ -272,8 +277,10 @@ where
272277 /// The effect of `insert` depends on whether a height already exists. If it doesn't, the data
273278 /// we inserted and all pre-existing entries higher than it will be re-inserted after it. If the
274279 /// height already existed and has a conflicting block hash then it will be purged along with
275- /// all entries following it. The returned chain will have a tip of the data passed in. Of
276- /// course, if the data was already present then this just returns `self`.
280+ /// all entries following it. If the existing checkpoint at height is a placeholder where
281+ /// `data: None` with the same hash, then the `data` is inserted to make a complete checkpoint.
282+ /// The returned chain will have a tip of the data passed in. If the data was already present
283+ /// then this just returns `self`. This method does not create new placeholders.
277284 ///
278285 /// # Panics
279286 ///
You can’t perform that action at this time.
0 commit comments