The aim of this change is to make the Doc type more safe to use by approaching
the design via [Parse don’t validate][0] approach.
The problem with the previous approach was that all field were pub and thus a
Doc<Verified> could easily be mutated and serialized. Granted, the code that
used the serialization would tend to verify the Doc first, however, this
approach ensures that only a verified Doc can be serialized. It also meant
that trying to add new data that would follow the parse approach would require
more generic parameters on top of the existing PhantomData parameter, i.e. we
need to do something like: Doc<RawField, V> -> Doc<ValidField, V>.
The new approach splits the type into two separate types: DocMut and Doc.
The former is allowed to be mutated at will, and uses types that are less
strict. The latter is the valid type that can only be constructed by validating
a DocMut (or the initial constructor). The Doc type’s fields can then only
be accessed by read-only methods.
Solves the problems above by only allowing mutations to DocMut, as well as,
new fields being added to DocMut which are then validated via
DocMut::verified.
The aim of this change is to make the Doc type more safe to use by approaching
the design via [Parse don’t validate][0] approach.
The problem with the previous approach was that all field were pub and thus a
Doc<Verified> could easily be mutated and serialized. Granted, the code that
used the serialization would tend to verify the Doc first, however, this
approach ensures that only a verified Doc can be serialized. It also meant
that trying to add new data that would follow the parse approach would require
more generic parameters on top of the existing PhantomData parameter, i.e. we
need to do something like: Doc<RawField, V> -> Doc<ValidField, V>.
The new approach splits the type into two separate types: DocMut and Doc.
The former is allowed to be mutated at will, and uses types that are less
strict. The latter is the valid type that can only be constructed by validating
a DocMut (or the initial constructor). The Doc type’s fields can then only
be accessed by read-only methods.
Solves the problems above by only allowing mutations to DocMut, as well as,
new fields being added to DocMut which are then validated via
DocMut::verified.
Changes:
- Renamed DocMut to RawDoc
- Renamed
into_muttoedit - Use
Doc::editeverywhere and removeFrom<Doc> for RawDocimpl - Introduce
Doc::with_editsto for a slightly nicer API in some sections Threshold::newtakesDelegatesto ensure it is always constructed safely- Changed
Delegatesconstructor to removeHashSetand use counter for checking number of delegates. - Added a test for checking verifying a Doc de-deuplicates DIDs
- Fix documentation indentation
Changes:
- Simplify Delegates::new constructor to use
Vecand use thelenfor checking when it exceeds the max. - Fix documentation links
- Change
blob_atfrompubtopub(crate)
Changes:
- Fix length check to go after we have pushed
- Add test case for maximum number of delegates
Changes:
- Check length before pushing, and do so after
containscheck