Commit 3f98190
committed
c209ce8 polynomial: expand unit tests (Andrew Poelstra)
dfc29ad fieldvec: add a bunch of unit tests (Andrew Poelstra)
0e3d954 polynomial: make Eq/PartialEq take leading zeros into account (Andrew Poelstra)
d08da46 correction: introduce CorrectableError trait (Andrew Poelstra)
4c6010e primitives: introduce InvalidResidueError (Andrew Poelstra)
b76adbe polynomial: add some extra functionality enabled by FieldVec (Andrew Poelstra)
690fc7d polynomial: use FieldVec in Polynomial (Andrew Poelstra)
f2ec582 primitives: introduce FieldVec type (Andrew Poelstra)
Pull request description:
This introduces a new internal type `FieldVec` which is basically a backing array for checksum residues with some fiddly logic to work in a noalloc context.
Unlike ArrayVec or other similar types, this one's semantics are "an unbounded vector if you have an allocator, a bounded vector otherwise". If you go outside of the bounds without an allocator the code will panic, but our use of it ensures that this is never exposed to a user.
It also assumes that it's holding a `Default` type which lets us avoid unsafety (and dismisses the potential performance cost because this array is never expected to have more than 10 or 20 elements, even when it is "unbounded").
Using this backing, it improves `Polynomial` and removes the alloc bound from it; using this, it puts `Polynomial` into a new `InvalidResidueError` type, which will allow users to extract the necessary information from a checksum error to run the error correction algorithm. (The resulting change to an error type makes this an API-breaking change, though I don't think that anything else here is API-breaking.)
The next PR will actually implement correction :).
ACKs for top commit:
tcharding:
ACK c209ce8
clarkmoody:
ACK c209ce8
Tree-SHA512: 16a23bd88101be549c9d50f6b32f669688dfb1efbd6e842c1c3db2203d1775e647f0909c4a65191fd332cd07778c0431ae7b4635909a00f7c2d86135fae042e2
File tree
9 files changed
+1061
-167
lines changed- src
- primitives
- tests
9 files changed
+1061
-167
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
| |||
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| 169 | + | |
167 | 170 | | |
168 | 171 | | |
169 | 172 | | |
| |||
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
219 | | - | |
220 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | 227 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | 9 | | |
13 | | - | |
| 10 | + | |
14 | 11 | | |
15 | | - | |
16 | 12 | | |
17 | 13 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 14 | + | |
21 | 15 | | |
22 | 16 | | |
23 | 17 | | |
| |||
169 | 163 | | |
170 | 164 | | |
171 | 165 | | |
172 | | - | |
173 | 166 | | |
174 | 167 | | |
175 | | - | |
| 168 | + | |
176 | 169 | | |
177 | 170 | | |
178 | 171 | | |
179 | 172 | | |
180 | 173 | | |
181 | 174 | | |
182 | 175 | | |
183 | | - | |
184 | 176 | | |
185 | 177 | | |
186 | 178 | | |
| |||
225 | 217 | | |
226 | 218 | | |
227 | 219 | | |
228 | | - | |
| 220 | + | |
229 | 221 | | |
230 | 222 | | |
231 | 223 | | |
| |||
235 | 227 | | |
236 | 228 | | |
237 | 229 | | |
238 | | - | |
239 | 230 | | |
240 | 231 | | |
241 | 232 | | |
242 | 233 | | |
243 | 234 | | |
244 | 235 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 236 | + | |
252 | 237 | | |
253 | 238 | | |
254 | | - | |
| 239 | + | |
255 | 240 | | |
256 | 241 | | |
257 | 242 | | |
| |||
278 | 263 | | |
279 | 264 | | |
280 | 265 | | |
281 | | - | |
| 266 | + | |
282 | 267 | | |
283 | | - | |
| 268 | + | |
284 | 269 | | |
285 | 270 | | |
286 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
280 | | - | |
281 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
282 | 284 | | |
283 | 285 | | |
284 | 286 | | |
| |||
952 | 954 | | |
953 | 955 | | |
954 | 956 | | |
955 | | - | |
| 957 | + | |
956 | 958 | | |
957 | 959 | | |
958 | 960 | | |
| |||
963 | 965 | | |
964 | 966 | | |
965 | 967 | | |
966 | | - | |
| 968 | + | |
967 | 969 | | |
968 | 970 | | |
969 | 971 | | |
| |||
976 | 978 | | |
977 | 979 | | |
978 | 980 | | |
979 | | - | |
| 981 | + | |
| 982 | + | |
980 | 983 | | |
981 | 984 | | |
982 | 985 | | |
983 | 986 | | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
984 | 1031 | | |
985 | 1032 | | |
986 | 1033 | | |
| |||
1065 | 1112 | | |
1066 | 1113 | | |
1067 | 1114 | | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
1068 | 1118 | | |
1069 | 1119 | | |
1070 | 1120 | | |
| |||
1117 | 1167 | | |
1118 | 1168 | | |
1119 | 1169 | | |
1120 | | - | |
| 1170 | + | |
1121 | 1171 | | |
1122 | 1172 | | |
1123 | 1173 | | |
| |||
1178 | 1228 | | |
1179 | 1229 | | |
1180 | 1230 | | |
1181 | | - | |
| 1231 | + | |
1182 | 1232 | | |
1183 | 1233 | | |
1184 | 1234 | | |
| |||
1212 | 1262 | | |
1213 | 1263 | | |
1214 | 1264 | | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
1215 | 1274 | | |
1216 | 1275 | | |
1217 | 1276 | | |
| |||
0 commit comments