tor/src/rust/protover
Isis Lovecruft 2eb1b7f2fd
rust: Add new ProtoverVote type and refactor functions to methods.
This adds a new type for votes upon `protover::ProtoEntry`s (technically, on
`protover::UnvalidatedProtoEntry`s, because the C code does not validate based
upon currently known protocols when voting, in order to maintain
future-compatibility), and converts several functions which would have operated
on this datatype into methods for ease-of-use and readability.

This also fixes a behavioural differentce to the C version of
protover_compute_vote().  The C version of protover_compute_vote() calls
expand_protocol_list() which checks if there would be too many subprotocols *or*
expanded individual version numbers, i.e. more than MAX_PROTOCOLS_TO_EXPAND, and
does this *per vote* (but only in compute_vote(), everywhere else in the C seems
to only care about the number of subprotocols, not the number of individual
versions).  We need to match its behaviour in Rust and ensure we're not allowing
more than it would to get the votes to match.

 * ADD new `protover::ProtoverVote` datatype.
 * REMOVE the `protover::compute_vote()` function and refactor it into an
   equivalent-in-behaviour albeit more memory-efficient voting algorithm based
   on the new underlying `protover::protoset::ProtoSet` datatype, as
   `ProtoverVote::compute()`.
 * REMOVE the `protover::write_vote_to_string()` function, since this
   functionality is now generated by the impl_to_string_for_proto_entry!() macro
   for both `ProtoEntry` and `UnvalidatedProtoEntry` (the latter of which is the
   correct type to return from a voting protocol instance, since the entity
   voting may not know of all protocols being voted upon or known about by other
   voting parties).
 * FIXES part of #24031: https://bugs.torproject.org/24031

rust: Fix a difference in compute_vote() behaviour to C version.
2018-04-02 19:34:24 +00:00
..
tests Add missing copyright/license statements on all .rs files 2017-10-27 10:02:08 -04:00
Cargo.toml maint: Update Rust libc dependency from 0.2.22 to 0.2.39. 2018-03-21 17:04:28 -04:00
errors.rs rust: Implement error types for Rust protover implementation. 2018-04-02 19:24:32 +00:00
ffi.rs rust: Add new protover::UnknownProtocol type. 2018-04-02 19:27:51 +00:00
lib.rs rust: Implement more memory-efficient protover datatype. 2018-04-02 19:26:26 +00:00
protoset.rs rust: Implement more memory-efficient protover datatype. 2018-04-02 19:26:26 +00:00
protover.rs rust: Add new ProtoverVote type and refactor functions to methods. 2018-04-02 19:34:24 +00:00