/__w/smoldot/smoldot/repo/lib/src/header/grandpa.rs
Line | Count | Source (jump to first uncovered line) |
1 | | // Smoldot |
2 | | // Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. |
3 | | // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 |
4 | | |
5 | | // This program is free software: you can redistribute it and/or modify |
6 | | // it under the terms of the GNU General Public License as published by |
7 | | // the Free Software Foundation, either version 3 of the License, or |
8 | | // (at your option) any later version. |
9 | | |
10 | | // This program is distributed in the hope that it will be useful, |
11 | | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | | // GNU General Public License for more details. |
14 | | |
15 | | // You should have received a copy of the GNU General Public License |
16 | | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | | |
18 | | use super::Error; |
19 | | use crate::util; |
20 | | |
21 | | use alloc::vec::Vec; |
22 | | use core::{cmp, fmt, iter, num::NonZeroU64, slice}; |
23 | | |
24 | | /// A consensus log item for GrandPa. |
25 | | #[derive(Debug, Clone, PartialEq, Eq)] |
26 | | pub enum GrandpaConsensusLogRef<'a> { |
27 | | /// Schedule an authority set change. |
28 | | /// |
29 | | /// The earliest digest of this type in a single block will be respected, |
30 | | /// provided that there is no `ForcedChange` digest. If there is, then the |
31 | | /// `ForcedChange` will take precedence. |
32 | | /// |
33 | | /// No change should be scheduled if one is already and the delay has not |
34 | | /// passed completely. |
35 | | /// |
36 | | /// This should be a pure function: i.e. as long as the runtime can interpret |
37 | | /// the digest type it should return the same result regardless of the current |
38 | | /// state. |
39 | | ScheduledChange(GrandpaScheduledChangeRef<'a>), |
40 | | |
41 | | /// Force an authority set change. |
42 | | /// |
43 | | /// Forced changes are applied after a delay of _imported_ blocks, |
44 | | /// while pending changes are applied after a delay of _finalized_ blocks. |
45 | | /// |
46 | | /// The earliest digest of this type in a single block will be respected, |
47 | | /// with others ignored. |
48 | | /// |
49 | | /// No change should be scheduled if one is already and the delay has not |
50 | | /// passed completely. |
51 | | /// |
52 | | /// This should be a pure function: i.e. as long as the runtime can interpret |
53 | | /// the digest type it should return the same result regardless of the current |
54 | | /// state. |
55 | | ForcedChange { |
56 | | reset_block_height: u64, |
57 | | change: GrandpaScheduledChangeRef<'a>, |
58 | | }, |
59 | | |
60 | | /// Note that the authority with given index is disabled until the next change. |
61 | | OnDisabled(u64), |
62 | | |
63 | | /// A signal to pause the current authority set after the given delay. |
64 | | /// After finalizing the block at _delay_ the authorities should stop voting. |
65 | | Pause(u64), |
66 | | |
67 | | /// A signal to resume the current authority set after the given delay. |
68 | | /// After authoring the block at _delay_ the authorities should resume voting. |
69 | | Resume(u64), |
70 | | } |
71 | | |
72 | | impl<'a> GrandpaConsensusLogRef<'a> { |
73 | | /// Decodes a [`GrandpaConsensusLogRef`] from a slice of bytes. |
74 | 25 | pub fn from_slice(slice: &'a [u8], block_number_bytes: usize) -> Result<Self, Error> { |
75 | 25 | Ok( |
76 | 25 | nom::combinator::all_consuming(grandpa_consensus_log_ref(block_number_bytes))(slice) |
77 | 25 | .map_err(|_: nom::Err<(&[u8], nom::error::ErrorKind)>| { |
78 | 0 | Error::GrandpaConsensusLogDecodeError |
79 | 25 | })?0 Unexecuted instantiation: _RNCNvMNtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB4_22GrandpaConsensusLogRef10from_slice0B8_ Unexecuted instantiation: _RNCNvMNtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB4_22GrandpaConsensusLogRef10from_slice0B8_ |
80 | | .1, |
81 | | ) |
82 | 25 | } _RNvMNtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB2_22GrandpaConsensusLogRef10from_slice Line | Count | Source | 74 | 25 | pub fn from_slice(slice: &'a [u8], block_number_bytes: usize) -> Result<Self, Error> { | 75 | 25 | Ok( | 76 | 25 | nom::combinator::all_consuming(grandpa_consensus_log_ref(block_number_bytes))(slice) | 77 | 25 | .map_err(|_: nom::Err<(&[u8], nom::error::ErrorKind)>| { | 78 | | Error::GrandpaConsensusLogDecodeError | 79 | 25 | })?0 | 80 | | .1, | 81 | | ) | 82 | 25 | } |
Unexecuted instantiation: _RNvMNtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB2_22GrandpaConsensusLogRef10from_slice |
83 | | |
84 | | /// Returns an iterator to list of buffers which, when concatenated, produces the SCALE |
85 | | /// encoding of that object. |
86 | 12 | pub fn scale_encoding( |
87 | 12 | &self, |
88 | 12 | block_number_bytes: usize, |
89 | 12 | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a { |
90 | 12 | let index = iter::once(match self { |
91 | 1 | GrandpaConsensusLogRef::ScheduledChange(_) => [1], |
92 | 0 | GrandpaConsensusLogRef::ForcedChange { .. } => [2], |
93 | 11 | GrandpaConsensusLogRef::OnDisabled(_) => [3], |
94 | 0 | GrandpaConsensusLogRef::Pause(_) => [4], |
95 | 0 | GrandpaConsensusLogRef::Resume(_) => [5], |
96 | | }); |
97 | | |
98 | 12 | let body = match self { |
99 | 1 | GrandpaConsensusLogRef::ScheduledChange(change) => either::Left(either::Left( |
100 | 1 | change |
101 | 1 | .scale_encoding(block_number_bytes) |
102 | 1 | .map(either::Left) |
103 | 1 | .map(either::Left), |
104 | 1 | )), |
105 | | GrandpaConsensusLogRef::ForcedChange { |
106 | 0 | reset_block_height, |
107 | 0 | change, |
108 | 0 | } => { |
109 | 0 | let mut data = Vec::with_capacity(block_number_bytes); |
110 | 0 | data.extend_from_slice(&reset_block_height.to_le_bytes()); |
111 | 0 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` |
112 | 0 | data.resize(block_number_bytes, 0); |
113 | 0 | either::Left(either::Right( |
114 | 0 | iter::once(either::Right(either::Right(data))).chain( |
115 | 0 | change |
116 | 0 | .scale_encoding(block_number_bytes) |
117 | 0 | .map(either::Right) |
118 | 0 | .map(either::Left), |
119 | 0 | ), |
120 | 0 | )) |
121 | | } |
122 | 11 | GrandpaConsensusLogRef::OnDisabled(n) => { |
123 | 11 | either::Right(iter::once(either::Right(either::Left(n.to_le_bytes())))) |
124 | | } |
125 | 0 | GrandpaConsensusLogRef::Pause(n) => { |
126 | 0 | let mut data = Vec::with_capacity(block_number_bytes); |
127 | 0 | data.extend_from_slice(&n.to_le_bytes()); |
128 | 0 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` |
129 | 0 | data.resize(block_number_bytes, 0); |
130 | 0 | either::Right(iter::once(either::Right(either::Right(data)))) |
131 | | } |
132 | 0 | GrandpaConsensusLogRef::Resume(n) => { |
133 | 0 | let mut data = Vec::with_capacity(block_number_bytes); |
134 | 0 | data.extend_from_slice(&n.to_le_bytes()); |
135 | 0 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` |
136 | 0 | data.resize(block_number_bytes, 0); |
137 | 0 | either::Right(iter::once(either::Right(either::Right(data)))) |
138 | | } |
139 | | }; |
140 | | |
141 | 12 | index.map(either::Left).chain(body.map(either::Right)) |
142 | 12 | } _RNvMNtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB2_22GrandpaConsensusLogRef14scale_encoding Line | Count | Source | 86 | 12 | pub fn scale_encoding( | 87 | 12 | &self, | 88 | 12 | block_number_bytes: usize, | 89 | 12 | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a { | 90 | 12 | let index = iter::once(match self { | 91 | 1 | GrandpaConsensusLogRef::ScheduledChange(_) => [1], | 92 | 0 | GrandpaConsensusLogRef::ForcedChange { .. } => [2], | 93 | 11 | GrandpaConsensusLogRef::OnDisabled(_) => [3], | 94 | 0 | GrandpaConsensusLogRef::Pause(_) => [4], | 95 | 0 | GrandpaConsensusLogRef::Resume(_) => [5], | 96 | | }); | 97 | | | 98 | 12 | let body = match self { | 99 | 1 | GrandpaConsensusLogRef::ScheduledChange(change) => either::Left(either::Left( | 100 | 1 | change | 101 | 1 | .scale_encoding(block_number_bytes) | 102 | 1 | .map(either::Left) | 103 | 1 | .map(either::Left), | 104 | 1 | )), | 105 | | GrandpaConsensusLogRef::ForcedChange { | 106 | 0 | reset_block_height, | 107 | 0 | change, | 108 | 0 | } => { | 109 | 0 | let mut data = Vec::with_capacity(block_number_bytes); | 110 | 0 | data.extend_from_slice(&reset_block_height.to_le_bytes()); | 111 | 0 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` | 112 | 0 | data.resize(block_number_bytes, 0); | 113 | 0 | either::Left(either::Right( | 114 | 0 | iter::once(either::Right(either::Right(data))).chain( | 115 | 0 | change | 116 | 0 | .scale_encoding(block_number_bytes) | 117 | 0 | .map(either::Right) | 118 | 0 | .map(either::Left), | 119 | 0 | ), | 120 | 0 | )) | 121 | | } | 122 | 11 | GrandpaConsensusLogRef::OnDisabled(n) => { | 123 | 11 | either::Right(iter::once(either::Right(either::Left(n.to_le_bytes())))) | 124 | | } | 125 | 0 | GrandpaConsensusLogRef::Pause(n) => { | 126 | 0 | let mut data = Vec::with_capacity(block_number_bytes); | 127 | 0 | data.extend_from_slice(&n.to_le_bytes()); | 128 | 0 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` | 129 | 0 | data.resize(block_number_bytes, 0); | 130 | 0 | either::Right(iter::once(either::Right(either::Right(data)))) | 131 | | } | 132 | 0 | GrandpaConsensusLogRef::Resume(n) => { | 133 | 0 | let mut data = Vec::with_capacity(block_number_bytes); | 134 | 0 | data.extend_from_slice(&n.to_le_bytes()); | 135 | 0 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` | 136 | 0 | data.resize(block_number_bytes, 0); | 137 | 0 | either::Right(iter::once(either::Right(either::Right(data)))) | 138 | | } | 139 | | }; | 140 | | | 141 | 12 | index.map(either::Left).chain(body.map(either::Right)) | 142 | 12 | } |
Unexecuted instantiation: _RNvMNtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB2_22GrandpaConsensusLogRef14scale_encoding |
143 | | } |
144 | | |
145 | | impl<'a> From<&'a GrandpaConsensusLog> for GrandpaConsensusLogRef<'a> { |
146 | 0 | fn from(a: &'a GrandpaConsensusLog) -> Self { |
147 | 0 | match a { |
148 | 0 | GrandpaConsensusLog::ScheduledChange(v) => { |
149 | 0 | GrandpaConsensusLogRef::ScheduledChange(v.into()) |
150 | | } |
151 | | GrandpaConsensusLog::ForcedChange { |
152 | 0 | reset_block_height, |
153 | 0 | change, |
154 | 0 | } => GrandpaConsensusLogRef::ForcedChange { |
155 | 0 | reset_block_height: *reset_block_height, |
156 | 0 | change: change.into(), |
157 | 0 | }, |
158 | 0 | GrandpaConsensusLog::OnDisabled(v) => GrandpaConsensusLogRef::OnDisabled(*v), |
159 | 0 | GrandpaConsensusLog::Pause(v) => GrandpaConsensusLogRef::Pause(*v), |
160 | 0 | GrandpaConsensusLog::Resume(v) => GrandpaConsensusLogRef::Resume(*v), |
161 | | } |
162 | 0 | } Unexecuted instantiation: _RNvXs_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB4_22GrandpaConsensusLogRefINtNtCsaYZPK01V26L_4core7convert4FromRNtB4_19GrandpaConsensusLogE4from Unexecuted instantiation: _RNvXs_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB4_22GrandpaConsensusLogRefINtNtCsaYZPK01V26L_4core7convert4FromRNtB4_19GrandpaConsensusLogE4from |
163 | | } |
164 | | |
165 | | /// A consensus log item for GrandPa. |
166 | | #[derive(Debug, Clone, PartialEq, Eq)] |
167 | | pub enum GrandpaConsensusLog { |
168 | | /// Schedule an authority set change. |
169 | | /// |
170 | | /// The earliest digest of this type in a single block will be respected, |
171 | | /// provided that there is no `ForcedChange` digest. If there is, then the |
172 | | /// `ForcedChange` will take precedence. |
173 | | /// |
174 | | /// No change should be scheduled if one is already and the delay has not |
175 | | /// passed completely. |
176 | | /// |
177 | | /// This should be a pure function: i.e. as long as the runtime can interpret |
178 | | /// the digest type it should return the same result regardless of the current |
179 | | /// state. |
180 | | ScheduledChange(GrandpaScheduledChange), |
181 | | |
182 | | /// Force an authority set change. |
183 | | /// |
184 | | /// Forced changes are applied after a delay of _imported_ blocks, |
185 | | /// while pending changes are applied after a delay of _finalized_ blocks. |
186 | | /// |
187 | | /// The earliest digest of this type in a single block will be respected, |
188 | | /// with others ignored. |
189 | | /// |
190 | | /// No change should be scheduled if one is already and the delay has not |
191 | | /// passed completely. |
192 | | /// |
193 | | /// This should be a pure function: i.e. as long as the runtime can interpret |
194 | | /// the digest type it should return the same result regardless of the current |
195 | | /// state. |
196 | | ForcedChange { |
197 | | reset_block_height: u64, |
198 | | change: GrandpaScheduledChange, |
199 | | }, |
200 | | |
201 | | /// Note that the authority with given index is disabled until the next change. |
202 | | OnDisabled(u64), |
203 | | |
204 | | /// A signal to pause the current authority set after the given delay. |
205 | | /// After finalizing the block at _delay_ the authorities should stop voting. |
206 | | Pause(u64), |
207 | | |
208 | | /// A signal to resume the current authority set after the given delay. |
209 | | /// After authoring the block at _delay_ the authorities should resume voting. |
210 | | Resume(u64), |
211 | | } |
212 | | |
213 | | impl<'a> From<GrandpaConsensusLogRef<'a>> for GrandpaConsensusLog { |
214 | 0 | fn from(a: GrandpaConsensusLogRef<'a>) -> Self { |
215 | 0 | match a { |
216 | 0 | GrandpaConsensusLogRef::ScheduledChange(v) => { |
217 | 0 | GrandpaConsensusLog::ScheduledChange(v.into()) |
218 | | } |
219 | | GrandpaConsensusLogRef::ForcedChange { |
220 | 0 | reset_block_height, |
221 | 0 | change, |
222 | 0 | } => GrandpaConsensusLog::ForcedChange { |
223 | 0 | reset_block_height, |
224 | 0 | change: change.into(), |
225 | 0 | }, |
226 | 0 | GrandpaConsensusLogRef::OnDisabled(v) => GrandpaConsensusLog::OnDisabled(v), |
227 | 0 | GrandpaConsensusLogRef::Pause(v) => GrandpaConsensusLog::Pause(v), |
228 | 0 | GrandpaConsensusLogRef::Resume(v) => GrandpaConsensusLog::Resume(v), |
229 | | } |
230 | 0 | } Unexecuted instantiation: _RNvXs0_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_19GrandpaConsensusLogINtNtCsaYZPK01V26L_4core7convert4FromNtB5_22GrandpaConsensusLogRefE4from Unexecuted instantiation: _RNvXs0_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_19GrandpaConsensusLogINtNtCsaYZPK01V26L_4core7convert4FromNtB5_22GrandpaConsensusLogRefE4from |
231 | | } |
232 | | |
233 | | /// A scheduled change of authority set. |
234 | | #[derive(Debug, Clone, PartialEq, Eq)] |
235 | | pub struct GrandpaScheduledChangeRef<'a> { |
236 | | /// The new authorities after the change, along with their respective weights. |
237 | | pub next_authorities: GrandpaAuthoritiesIter<'a>, |
238 | | /// The number of blocks to delay. |
239 | | pub delay: u64, |
240 | | } |
241 | | |
242 | | impl<'a> GrandpaScheduledChangeRef<'a> { |
243 | | /// Returns an iterator to list of buffers which, when concatenated, produces the SCALE |
244 | | /// encoding of that object. |
245 | 1 | pub fn scale_encoding( |
246 | 1 | &self, |
247 | 1 | block_number_bytes: usize, |
248 | 1 | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a { |
249 | 1 | let header = util::encode_scale_compact_usize(self.next_authorities.len()); |
250 | 1 | |
251 | 1 | let mut delay = Vec::with_capacity(block_number_bytes); |
252 | 1 | delay.extend_from_slice(&self.delay.to_le_bytes()); |
253 | 1 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` |
254 | 1 | delay.resize(block_number_bytes, 0); |
255 | 1 | |
256 | 1 | iter::once(either::Left(either::Left(header))) |
257 | 1 | .chain( |
258 | 1 | self.next_authorities |
259 | 1 | .clone() |
260 | 900 | .flat_map(|a| a.scale_encoding()) _RNCNvMs1_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB7_25GrandpaScheduledChangeRef14scale_encoding0Bb_ Line | Count | Source | 260 | 900 | .flat_map(|a| a.scale_encoding()) |
Unexecuted instantiation: _RNCNvMs1_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB7_25GrandpaScheduledChangeRef14scale_encoding0Bb_ |
261 | 1 | .map(either::Right), |
262 | 1 | ) |
263 | 1 | .chain(iter::once(either::Left(either::Right(delay)))) |
264 | 1 | } _RNvMs1_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_25GrandpaScheduledChangeRef14scale_encoding Line | Count | Source | 245 | 1 | pub fn scale_encoding( | 246 | 1 | &self, | 247 | 1 | block_number_bytes: usize, | 248 | 1 | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a { | 249 | 1 | let header = util::encode_scale_compact_usize(self.next_authorities.len()); | 250 | 1 | | 251 | 1 | let mut delay = Vec::with_capacity(block_number_bytes); | 252 | 1 | delay.extend_from_slice(&self.delay.to_le_bytes()); | 253 | 1 | // TODO: unclear what to do if the block number doesn't fit within `expected_block_number_bytes` | 254 | 1 | delay.resize(block_number_bytes, 0); | 255 | 1 | | 256 | 1 | iter::once(either::Left(either::Left(header))) | 257 | 1 | .chain( | 258 | 1 | self.next_authorities | 259 | 1 | .clone() | 260 | 1 | .flat_map(|a| a.scale_encoding()) | 261 | 1 | .map(either::Right), | 262 | 1 | ) | 263 | 1 | .chain(iter::once(either::Left(either::Right(delay)))) | 264 | 1 | } |
Unexecuted instantiation: _RNvMs1_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_25GrandpaScheduledChangeRef14scale_encoding |
265 | | } |
266 | | |
267 | | impl<'a> From<&'a GrandpaScheduledChange> for GrandpaScheduledChangeRef<'a> { |
268 | 0 | fn from(gp: &'a GrandpaScheduledChange) -> Self { |
269 | 0 | GrandpaScheduledChangeRef { |
270 | 0 | next_authorities: GrandpaAuthoritiesIter(GrandpaAuthoritiesIterInner::Decoded( |
271 | 0 | gp.next_authorities.iter(), |
272 | 0 | )), |
273 | 0 | delay: gp.delay, |
274 | 0 | } |
275 | 0 | } Unexecuted instantiation: _RNvXs2_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_25GrandpaScheduledChangeRefINtNtCsaYZPK01V26L_4core7convert4FromRNtB5_22GrandpaScheduledChangeE4from Unexecuted instantiation: _RNvXs2_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_25GrandpaScheduledChangeRefINtNtCsaYZPK01V26L_4core7convert4FromRNtB5_22GrandpaScheduledChangeE4from |
276 | | } |
277 | | |
278 | | /// A scheduled change of authority set. |
279 | | #[derive(Debug, Clone, PartialEq, Eq)] |
280 | | pub struct GrandpaScheduledChange { |
281 | | /// The new authorities after the change, along with their respective weights. |
282 | | pub next_authorities: Vec<GrandpaAuthority>, |
283 | | /// The number of blocks to delay. |
284 | | pub delay: u64, |
285 | | } |
286 | | |
287 | | impl<'a> From<GrandpaScheduledChangeRef<'a>> for GrandpaScheduledChange { |
288 | 0 | fn from(gp: GrandpaScheduledChangeRef<'a>) -> Self { |
289 | 0 | GrandpaScheduledChange { |
290 | 0 | next_authorities: gp.next_authorities.map(Into::into).collect(), |
291 | 0 | delay: gp.delay, |
292 | 0 | } |
293 | 0 | } Unexecuted instantiation: _RNvXs3_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_22GrandpaScheduledChangeINtNtCsaYZPK01V26L_4core7convert4FromNtB5_25GrandpaScheduledChangeRefE4from Unexecuted instantiation: _RNvXs3_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_22GrandpaScheduledChangeINtNtCsaYZPK01V26L_4core7convert4FromNtB5_25GrandpaScheduledChangeRefE4from |
294 | | } |
295 | | |
296 | | /// List of authorities in a GrandPa context. |
297 | | #[derive(Clone)] |
298 | | pub struct GrandpaAuthoritiesIter<'a>(GrandpaAuthoritiesIterInner<'a>); |
299 | | |
300 | | #[derive(Clone)] |
301 | | enum GrandpaAuthoritiesIterInner<'a> { |
302 | | Encoded(slice::Chunks<'a, u8>), |
303 | | Decoded(slice::Iter<'a, GrandpaAuthority>), |
304 | | } |
305 | | |
306 | | impl<'a> GrandpaAuthoritiesIter<'a> { |
307 | | /// Returns an iterator corresponding to the given slice. |
308 | 0 | pub fn new(slice: &'a [GrandpaAuthority]) -> Self { |
309 | 0 | GrandpaAuthoritiesIter(GrandpaAuthoritiesIterInner::Decoded(slice.iter())) |
310 | 0 | } Unexecuted instantiation: _RNvMs4_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIter3new Unexecuted instantiation: _RNvMs4_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIter3new |
311 | | } |
312 | | |
313 | | impl<'a> Iterator for GrandpaAuthoritiesIter<'a> { |
314 | | type Item = GrandpaAuthorityRef<'a>; |
315 | | |
316 | 901 | fn next(&mut self) -> Option<Self::Item> { |
317 | 901 | match &mut self.0 { |
318 | 0 | GrandpaAuthoritiesIterInner::Decoded(inner) => inner.next().map(Into::into), |
319 | 901 | GrandpaAuthoritiesIterInner::Encoded(inner) => { |
320 | 901 | let item900 = inner.next()?1 ; |
321 | 900 | Some( |
322 | 900 | nom::combinator::all_consuming::<_, _, (&[u8], nom::error::ErrorKind), _>( |
323 | 900 | grandpa_authority_ref, |
324 | 900 | )(item) |
325 | 900 | .unwrap() |
326 | 900 | .1, |
327 | 900 | ) |
328 | | } |
329 | | } |
330 | 901 | } _RNvXs5_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtNtNtCsaYZPK01V26L_4core4iter6traits8iterator8Iterator4next Line | Count | Source | 316 | 901 | fn next(&mut self) -> Option<Self::Item> { | 317 | 901 | match &mut self.0 { | 318 | 0 | GrandpaAuthoritiesIterInner::Decoded(inner) => inner.next().map(Into::into), | 319 | 901 | GrandpaAuthoritiesIterInner::Encoded(inner) => { | 320 | 901 | let item900 = inner.next()?1 ; | 321 | 900 | Some( | 322 | 900 | nom::combinator::all_consuming::<_, _, (&[u8], nom::error::ErrorKind), _>( | 323 | 900 | grandpa_authority_ref, | 324 | 900 | )(item) | 325 | 900 | .unwrap() | 326 | 900 | .1, | 327 | 900 | ) | 328 | | } | 329 | | } | 330 | 901 | } |
Unexecuted instantiation: _RNvXs5_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtNtNtCsaYZPK01V26L_4core4iter6traits8iterator8Iterator4next |
331 | | |
332 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { |
333 | 1 | match &self.0 { |
334 | 1 | GrandpaAuthoritiesIterInner::Encoded(inner) => inner.size_hint(), |
335 | 0 | GrandpaAuthoritiesIterInner::Decoded(inner) => inner.size_hint(), |
336 | | } |
337 | 1 | } _RNvXs5_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtNtNtCsaYZPK01V26L_4core4iter6traits8iterator8Iterator9size_hint Line | Count | Source | 332 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 333 | 1 | match &self.0 { | 334 | 1 | GrandpaAuthoritiesIterInner::Encoded(inner) => inner.size_hint(), | 335 | 0 | GrandpaAuthoritiesIterInner::Decoded(inner) => inner.size_hint(), | 336 | | } | 337 | 1 | } |
Unexecuted instantiation: _RNvXs5_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtNtNtCsaYZPK01V26L_4core4iter6traits8iterator8Iterator9size_hint |
338 | | } |
339 | | |
340 | | impl<'a> ExactSizeIterator for GrandpaAuthoritiesIter<'a> {} |
341 | | |
342 | | impl<'a> cmp::PartialEq<GrandpaAuthoritiesIter<'a>> for GrandpaAuthoritiesIter<'a> { |
343 | 0 | fn eq(&self, other: &GrandpaAuthoritiesIter<'a>) -> bool { |
344 | 0 | let mut a = self.clone(); |
345 | 0 | let mut b = other.clone(); |
346 | | loop { |
347 | 0 | match (a.next(), b.next()) { |
348 | 0 | (Some(a), Some(b)) if a == b => {} |
349 | 0 | (None, None) => return true, |
350 | 0 | _ => return false, |
351 | | } |
352 | | } |
353 | 0 | } Unexecuted instantiation: _RNvXs7_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtCsaYZPK01V26L_4core3cmp9PartialEq2eq Unexecuted instantiation: _RNvXs7_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtCsaYZPK01V26L_4core3cmp9PartialEq2eq |
354 | | } |
355 | | |
356 | | impl<'a> cmp::Eq for GrandpaAuthoritiesIter<'a> {} |
357 | | |
358 | | impl<'a> fmt::Debug for GrandpaAuthoritiesIter<'a> { |
359 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
360 | 0 | f.debug_list().entries(self.clone()).finish() |
361 | 0 | } Unexecuted instantiation: _RNvXs9_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtCsaYZPK01V26L_4core3fmt5Debug3fmt Unexecuted instantiation: _RNvXs9_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_22GrandpaAuthoritiesIterNtNtCsaYZPK01V26L_4core3fmt5Debug3fmt |
362 | | } |
363 | | |
364 | | #[derive(Debug, Copy, Clone, PartialEq, Eq)] |
365 | | pub struct GrandpaAuthorityRef<'a> { |
366 | | /// Ed25519 public key. |
367 | | pub public_key: &'a [u8; 32], |
368 | | |
369 | | /// Arbitrary number indicating the weight of the authority. |
370 | | /// |
371 | | /// This value can only be compared to other weight values. |
372 | | pub weight: NonZeroU64, |
373 | | } |
374 | | |
375 | | impl<'a> GrandpaAuthorityRef<'a> { |
376 | | /// Returns an iterator to list of buffers which, when concatenated, produces the SCALE |
377 | | /// encoding of that object. |
378 | 900 | pub fn scale_encoding( |
379 | 900 | &self, |
380 | 900 | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a { |
381 | 900 | iter::once(either::Right(self.public_key)) |
382 | 900 | .chain(iter::once(either::Left(self.weight.get().to_le_bytes()))) |
383 | 900 | } _RNvMsa_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_19GrandpaAuthorityRef14scale_encoding Line | Count | Source | 378 | 900 | pub fn scale_encoding( | 379 | 900 | &self, | 380 | 900 | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a { | 381 | 900 | iter::once(either::Right(self.public_key)) | 382 | 900 | .chain(iter::once(either::Left(self.weight.get().to_le_bytes()))) | 383 | 900 | } |
Unexecuted instantiation: _RNvMsa_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_19GrandpaAuthorityRef14scale_encoding |
384 | | } |
385 | | |
386 | | impl<'a> From<&'a GrandpaAuthority> for GrandpaAuthorityRef<'a> { |
387 | 0 | fn from(gp: &'a GrandpaAuthority) -> Self { |
388 | 0 | GrandpaAuthorityRef { |
389 | 0 | public_key: &gp.public_key, |
390 | 0 | weight: gp.weight, |
391 | 0 | } |
392 | 0 | } Unexecuted instantiation: _RNvXsb_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_19GrandpaAuthorityRefINtNtCsaYZPK01V26L_4core7convert4FromRNtB5_16GrandpaAuthorityE4from Unexecuted instantiation: _RNvXsb_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_19GrandpaAuthorityRefINtNtCsaYZPK01V26L_4core7convert4FromRNtB5_16GrandpaAuthorityE4from |
393 | | } |
394 | | |
395 | | #[derive(Debug, Copy, Clone, PartialEq, Eq)] |
396 | | pub struct GrandpaAuthority { |
397 | | /// Ed25519 public key. |
398 | | pub public_key: [u8; 32], |
399 | | |
400 | | /// Arbitrary number indicating the weight of the authority. |
401 | | /// |
402 | | /// This value can only be compared to other weight values. |
403 | | pub weight: NonZeroU64, |
404 | | } |
405 | | |
406 | | impl GrandpaAuthority { |
407 | | /// Returns an iterator to list of buffers which, when concatenated, produces the SCALE |
408 | | /// encoding of that object. |
409 | 0 | pub fn scale_encoding( |
410 | 0 | &'_ self, |
411 | 0 | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + '_> + Clone + '_ { |
412 | 0 | GrandpaAuthorityRef::from(self).scale_encoding() |
413 | 0 | } Unexecuted instantiation: _RNvMsc_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_16GrandpaAuthority14scale_encoding Unexecuted instantiation: _RNvMsc_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_16GrandpaAuthority14scale_encoding |
414 | | } |
415 | | |
416 | | impl<'a> From<GrandpaAuthorityRef<'a>> for GrandpaAuthority { |
417 | 0 | fn from(gp: GrandpaAuthorityRef<'a>) -> Self { |
418 | 0 | GrandpaAuthority { |
419 | 0 | public_key: *gp.public_key, |
420 | 0 | weight: gp.weight, |
421 | 0 | } |
422 | 0 | } Unexecuted instantiation: _RNvXsd_NtNtCsN16ciHI6Qf_7smoldot6header7grandpaNtB5_16GrandpaAuthorityINtNtCsaYZPK01V26L_4core7convert4FromNtB5_19GrandpaAuthorityRefE4from Unexecuted instantiation: _RNvXsd_NtNtCseuYC0Zibziv_7smoldot6header7grandpaNtB5_16GrandpaAuthorityINtNtCsaYZPK01V26L_4core7convert4FromNtB5_19GrandpaAuthorityRefE4from |
423 | | } |
424 | | |
425 | 25 | fn grandpa_consensus_log_ref< |
426 | 25 | 'a, |
427 | 25 | E: nom::error::ParseError<&'a [u8]> + nom::error::ContextError<&'a [u8]>, |
428 | 25 | >( |
429 | 25 | block_number_bytes: usize, |
430 | 25 | ) -> impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], GrandpaConsensusLogRef<'a>, E> { |
431 | 25 | nom::error::context( |
432 | 25 | "grandpa_consensus_log_ref", |
433 | 25 | nom::branch::alt(( |
434 | 25 | nom::combinator::map( |
435 | 25 | nom::sequence::preceded( |
436 | 25 | nom::bytes::streaming::tag(&[1]), |
437 | 25 | grandpa_scheduled_change_ref(block_number_bytes), |
438 | 25 | ), |
439 | 25 | GrandpaConsensusLogRef::ScheduledChange, |
440 | 25 | ), |
441 | 25 | nom::combinator::map( |
442 | 25 | nom::sequence::preceded( |
443 | 25 | nom::bytes::streaming::tag(&[2]), |
444 | 25 | nom::sequence::tuple(( |
445 | 25 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), |
446 | 25 | grandpa_scheduled_change_ref(block_number_bytes), |
447 | 25 | )), |
448 | 25 | ), |
449 | 25 | |(reset_block_height, change)| GrandpaConsensusLogRef::ForcedChange { |
450 | 0 | reset_block_height, |
451 | 0 | change, |
452 | 25 | }, Unexecuted instantiation: _RNCINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa25grandpa_consensus_log_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_ Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa25grandpa_consensus_log_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_ |
453 | 25 | ), |
454 | 25 | nom::combinator::map( |
455 | 25 | nom::sequence::preceded( |
456 | 25 | nom::bytes::streaming::tag(&[3]), |
457 | 25 | nom::number::streaming::le_u64, |
458 | 25 | ), |
459 | 25 | GrandpaConsensusLogRef::OnDisabled, |
460 | 25 | ), |
461 | 25 | nom::combinator::map( |
462 | 25 | nom::sequence::preceded( |
463 | 25 | nom::bytes::streaming::tag(&[4]), |
464 | 25 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), |
465 | 25 | ), |
466 | 25 | GrandpaConsensusLogRef::Pause, |
467 | 25 | ), |
468 | 25 | nom::combinator::map( |
469 | 25 | nom::sequence::preceded( |
470 | 25 | nom::bytes::streaming::tag(&[5]), |
471 | 25 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), |
472 | 25 | ), |
473 | 25 | GrandpaConsensusLogRef::Resume, |
474 | 25 | ), |
475 | 25 | )), |
476 | 25 | ) |
477 | 25 | } _RINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa25grandpa_consensus_log_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_ Line | Count | Source | 425 | 25 | fn grandpa_consensus_log_ref< | 426 | 25 | 'a, | 427 | 25 | E: nom::error::ParseError<&'a [u8]> + nom::error::ContextError<&'a [u8]>, | 428 | 25 | >( | 429 | 25 | block_number_bytes: usize, | 430 | 25 | ) -> impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], GrandpaConsensusLogRef<'a>, E> { | 431 | 25 | nom::error::context( | 432 | 25 | "grandpa_consensus_log_ref", | 433 | 25 | nom::branch::alt(( | 434 | 25 | nom::combinator::map( | 435 | 25 | nom::sequence::preceded( | 436 | 25 | nom::bytes::streaming::tag(&[1]), | 437 | 25 | grandpa_scheduled_change_ref(block_number_bytes), | 438 | 25 | ), | 439 | 25 | GrandpaConsensusLogRef::ScheduledChange, | 440 | 25 | ), | 441 | 25 | nom::combinator::map( | 442 | 25 | nom::sequence::preceded( | 443 | 25 | nom::bytes::streaming::tag(&[2]), | 444 | 25 | nom::sequence::tuple(( | 445 | 25 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), | 446 | 25 | grandpa_scheduled_change_ref(block_number_bytes), | 447 | 25 | )), | 448 | 25 | ), | 449 | 25 | |(reset_block_height, change)| GrandpaConsensusLogRef::ForcedChange { | 450 | | reset_block_height, | 451 | | change, | 452 | 25 | }, | 453 | 25 | ), | 454 | 25 | nom::combinator::map( | 455 | 25 | nom::sequence::preceded( | 456 | 25 | nom::bytes::streaming::tag(&[3]), | 457 | 25 | nom::number::streaming::le_u64, | 458 | 25 | ), | 459 | 25 | GrandpaConsensusLogRef::OnDisabled, | 460 | 25 | ), | 461 | 25 | nom::combinator::map( | 462 | 25 | nom::sequence::preceded( | 463 | 25 | nom::bytes::streaming::tag(&[4]), | 464 | 25 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), | 465 | 25 | ), | 466 | 25 | GrandpaConsensusLogRef::Pause, | 467 | 25 | ), | 468 | 25 | nom::combinator::map( | 469 | 25 | nom::sequence::preceded( | 470 | 25 | nom::bytes::streaming::tag(&[5]), | 471 | 25 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), | 472 | 25 | ), | 473 | 25 | GrandpaConsensusLogRef::Resume, | 474 | 25 | ), | 475 | 25 | )), | 476 | 25 | ) | 477 | 25 | } |
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa25grandpa_consensus_log_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_ |
478 | | |
479 | 50 | fn grandpa_scheduled_change_ref< |
480 | 50 | 'a, |
481 | 50 | E: nom::error::ParseError<&'a [u8]> + nom::error::ContextError<&'a [u8]>, |
482 | 50 | >( |
483 | 50 | block_number_bytes: usize, |
484 | 50 | ) -> impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], GrandpaScheduledChangeRef<'a>, E> { |
485 | 50 | nom::error::context( |
486 | 50 | "grandpa_scheduled_change_ref", |
487 | 50 | nom::combinator::map( |
488 | 50 | nom::sequence::tuple(( |
489 | 50 | nom::combinator::flat_map(util::nom_scale_compact_usize, |num_authorities| { |
490 | 3 | nom::combinator::map( |
491 | 3 | nom::combinator::recognize(nom::multi::fold_many_m_n( |
492 | 3 | num_authorities, |
493 | 3 | num_authorities, |
494 | 3 | grandpa_authority_ref, |
495 | 3 | || {}, _RNCNCINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00Ba_ Line | Count | Source | 495 | 3 | || {}, |
Unexecuted instantiation: _RNCNCINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00Ba_ |
496 | 1.99k | |(), _| (), _RNCNCINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0s_0Ba_ Line | Count | Source | 496 | 1.99k | |(), _| (), |
Unexecuted instantiation: _RNCNCINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0s_0Ba_ |
497 | 3 | )), |
498 | 3 | |bytes| { |
499 | 3 | GrandpaAuthoritiesIter(GrandpaAuthoritiesIterInner::Encoded( |
500 | 3 | bytes.chunks(40), |
501 | 3 | )) |
502 | 3 | }, _RNCNCINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0s0_0Ba_ Line | Count | Source | 498 | 3 | |bytes| { | 499 | 3 | GrandpaAuthoritiesIter(GrandpaAuthoritiesIterInner::Encoded( | 500 | 3 | bytes.chunks(40), | 501 | 3 | )) | 502 | 3 | }, |
Unexecuted instantiation: _RNCNCINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0s0_0Ba_ |
503 | 3 | ) |
504 | 50 | }), _RNCINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_ Line | Count | Source | 489 | 3 | nom::combinator::flat_map(util::nom_scale_compact_usize, |num_authorities| { | 490 | 3 | nom::combinator::map( | 491 | 3 | nom::combinator::recognize(nom::multi::fold_many_m_n( | 492 | 3 | num_authorities, | 493 | 3 | num_authorities, | 494 | 3 | grandpa_authority_ref, | 495 | 3 | || {}, | 496 | 3 | |(), _| (), | 497 | 3 | )), | 498 | 3 | |bytes| { | 499 | | GrandpaAuthoritiesIter(GrandpaAuthoritiesIterInner::Encoded( | 500 | | bytes.chunks(40), | 501 | | )) | 502 | 3 | }, | 503 | 3 | ) | 504 | 3 | }), |
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_ |
505 | 50 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), |
506 | 50 | )), |
507 | 50 | |(next_authorities, delay)| GrandpaScheduledChangeRef { |
508 | 3 | next_authorities, |
509 | 3 | delay, |
510 | 50 | }, _RNCINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEs_0B8_ Line | Count | Source | 507 | 3 | |(next_authorities, delay)| GrandpaScheduledChangeRef { | 508 | 3 | next_authorities, | 509 | 3 | delay, | 510 | 3 | }, |
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEs_0B8_ |
511 | 50 | ), |
512 | 50 | ) |
513 | 50 | } _RINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_ Line | Count | Source | 479 | 50 | fn grandpa_scheduled_change_ref< | 480 | 50 | 'a, | 481 | 50 | E: nom::error::ParseError<&'a [u8]> + nom::error::ContextError<&'a [u8]>, | 482 | 50 | >( | 483 | 50 | block_number_bytes: usize, | 484 | 50 | ) -> impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], GrandpaScheduledChangeRef<'a>, E> { | 485 | 50 | nom::error::context( | 486 | 50 | "grandpa_scheduled_change_ref", | 487 | 50 | nom::combinator::map( | 488 | 50 | nom::sequence::tuple(( | 489 | 50 | nom::combinator::flat_map(util::nom_scale_compact_usize, |num_authorities| { | 490 | | nom::combinator::map( | 491 | | nom::combinator::recognize(nom::multi::fold_many_m_n( | 492 | | num_authorities, | 493 | | num_authorities, | 494 | | grandpa_authority_ref, | 495 | | || {}, | 496 | | |(), _| (), | 497 | | )), | 498 | | |bytes| { | 499 | | GrandpaAuthoritiesIter(GrandpaAuthoritiesIterInner::Encoded( | 500 | | bytes.chunks(40), | 501 | | )) | 502 | | }, | 503 | | ) | 504 | 50 | }), | 505 | 50 | crate::util::nom_varsize_number_decode_u64(block_number_bytes), | 506 | 50 | )), | 507 | 50 | |(next_authorities, delay)| GrandpaScheduledChangeRef { | 508 | | next_authorities, | 509 | | delay, | 510 | 50 | }, | 511 | 50 | ), | 512 | 50 | ) | 513 | 50 | } |
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa28grandpa_scheduled_change_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_ |
514 | | |
515 | 2.89k | fn grandpa_authority_ref< |
516 | 2.89k | 'a, |
517 | 2.89k | E: nom::error::ParseError<&'a [u8]> + nom::error::ContextError<&'a [u8]>, |
518 | 2.89k | >( |
519 | 2.89k | bytes: &'a [u8], |
520 | 2.89k | ) -> nom::IResult<&'a [u8], GrandpaAuthorityRef<'a>, E> { |
521 | 2.89k | nom::error::context( |
522 | 2.89k | "grandpa_authority_ref", |
523 | 2.89k | nom::combinator::map( |
524 | 2.89k | nom::sequence::tuple(( |
525 | 2.89k | nom::bytes::streaming::take(32u32), |
526 | 2.89k | nom::combinator::map_opt(nom::number::streaming::le_u64, NonZeroU64::new), |
527 | 2.89k | )), |
528 | 2.89k | |(public_key, weight)| GrandpaAuthorityRef { |
529 | 2.89k | public_key: TryFrom::try_from(public_key).unwrap(), |
530 | 2.89k | weight, |
531 | 2.89k | }, _RNCINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa21grandpa_authority_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_ Line | Count | Source | 528 | 2.89k | |(public_key, weight)| GrandpaAuthorityRef { | 529 | 2.89k | public_key: TryFrom::try_from(public_key).unwrap(), | 530 | 2.89k | weight, | 531 | 2.89k | }, |
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa21grandpa_authority_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_ |
532 | 2.89k | ), |
533 | 2.89k | )(bytes) |
534 | 2.89k | } _RINvNtNtCsN16ciHI6Qf_7smoldot6header7grandpa21grandpa_authority_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_ Line | Count | Source | 515 | 2.89k | fn grandpa_authority_ref< | 516 | 2.89k | 'a, | 517 | 2.89k | E: nom::error::ParseError<&'a [u8]> + nom::error::ContextError<&'a [u8]>, | 518 | 2.89k | >( | 519 | 2.89k | bytes: &'a [u8], | 520 | 2.89k | ) -> nom::IResult<&'a [u8], GrandpaAuthorityRef<'a>, E> { | 521 | 2.89k | nom::error::context( | 522 | 2.89k | "grandpa_authority_ref", | 523 | 2.89k | nom::combinator::map( | 524 | 2.89k | nom::sequence::tuple(( | 525 | 2.89k | nom::bytes::streaming::take(32u32), | 526 | 2.89k | nom::combinator::map_opt(nom::number::streaming::le_u64, NonZeroU64::new), | 527 | 2.89k | )), | 528 | 2.89k | |(public_key, weight)| GrandpaAuthorityRef { | 529 | | public_key: TryFrom::try_from(public_key).unwrap(), | 530 | | weight, | 531 | 2.89k | }, | 532 | 2.89k | ), | 533 | 2.89k | )(bytes) | 534 | 2.89k | } |
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot6header7grandpa21grandpa_authority_refTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_ |