pub fn gen_cons_diff(base: &str, target: &str) -> Result<String, Error>Expand description
Generates a consensus diff.
This implementation is different from the one in CTor, because it uses a
different algorithm, namely Algorithm::Myers from the imara_diff
crate, which is more efficient than CTor in terms of runtime and about as
equally efficient as CTor in output size.
The CTor implementation makes heavy use of the fact that the input is a valid consensus and that the routers in it are ordered. This allows for some divide-and-conquer mechanisms and the cost of requiring more parsing.
Here, we only minimally parse the consensus, in order to only obtain the
first directory-signature item and to cut everything including itself off
from the input, as demanded by the specification.
All outputs of this function are guaranteed to work with this
apply_diff() implementation as a check is performed before returning,
because returning an unusable diff would be terrible.