@@ -113,17 +113,25 @@ impl IntoIterator for CheckPoint {
113
113
}
114
114
}
115
115
116
- /// Represents an update to [`LocalChain`].
116
+ /// A struct to update [`LocalChain`].
117
+ ///
118
+ /// This is used as input for [`LocalChain::apply_update`]. It contains the update's chain `tip` and
119
+ /// a `bool` which signals whether this update can introduce blocks below the original chain's tip
120
+ /// without invalidating blocks residing on the original chain. Block-by-block syncing mechanisms
121
+ /// would typically create updates that builds upon the previous tip. In this case, this paramater
122
+ /// would be `false`. Script-pubkey based syncing mechanisms may not introduce transactions in a
123
+ /// chronological order so some updates require introducing older blocks (to anchor older
124
+ /// transactions). For script-pubkey based syncing, this parameter would typically be `true`.
117
125
#[ derive( Debug , Clone ) ]
118
126
pub struct Update {
119
- /// The update's new [`CheckPoint`] tip.
127
+ /// The update chain 's new tip.
120
128
pub tip : CheckPoint ,
121
129
122
130
/// Whether the update allows for introducing older blocks.
123
131
///
124
- /// Refer to [`LocalChain::apply_update` ] for more.
132
+ /// Refer to [struct-level documentation ] for more.
125
133
///
126
- /// [`LocalChain::apply_update` ]: crate::local_chain::LocalChain::apply_update
134
+ /// [struct-level documentation ]: Update
127
135
pub introduce_older_blocks : bool ,
128
136
}
129
137
@@ -146,12 +154,6 @@ impl From<LocalChain> for BTreeMap<u32, BlockHash> {
146
154
}
147
155
}
148
156
149
- impl From < ChangeSet > for LocalChain {
150
- fn from ( value : ChangeSet ) -> Self {
151
- Self :: from_changeset ( value)
152
- }
153
- }
154
-
155
157
impl From < BTreeMap < u32 , BlockHash > > for LocalChain {
156
158
fn from ( value : BTreeMap < u32 , BlockHash > ) -> Self {
157
159
Self :: from_blocks ( value)
@@ -244,18 +246,9 @@ impl LocalChain {
244
246
self . tip . is_none ( )
245
247
}
246
248
247
- /// Updates [`Self`] with the given `update_tip`.
248
- ///
249
- /// `introduce_older_blocks` specifies whether the `update_tip`'s history can introduce blocks
250
- /// below the original chain's tip without invalidating blocks. Block-by-block syncing
251
- /// mechanisms would typically create updates that builds upon the previous tip. In this case,
252
- /// this paramater would be false. Script-pubkey based syncing mechanisms may not introduce
253
- /// transactions in a chronological order so some updates require introducing older blocks (to
254
- /// anchor older transactions). For script-pubkey based syncing, this parameter would typically
255
- /// be true.
249
+ /// Applies the given `update` to the chain.
256
250
///
257
- /// The method returns [`ChangeSet`] on success. This represents the applied changes to
258
- /// [`Self`].
251
+ /// The method returns [`ChangeSet`] on success. This represents the applied changes to `self`.
259
252
///
260
253
/// To update, the `update_tip` must *connect* with `self`. If `self` and `update_tip` has a
261
254
/// mutual checkpoint (same height and hash), it can connect if:
@@ -275,7 +268,7 @@ impl LocalChain {
275
268
///
276
269
/// An error will occur if the update does not correctly connect with `self`.
277
270
///
278
- /// Refer to [module-level documentation ] for more.
271
+ /// Refer to [`Update` ] for more about the update struct .
279
272
///
280
273
/// [module-level documentation]: crate::local_chain
281
274
pub fn apply_update ( & mut self , update : Update ) -> Result < ChangeSet , CannotConnectError > {
0 commit comments