entropyxyz / manul

Round-based distributed protocols
https://docs.rs/manul
GNU Affero General Public License v3.0
6 stars 1 forks source link

Determining that a round may produce a result #66

Closed fjarri closed 1 week ago

fjarri commented 3 weeks ago

In the current API, a round defines a fn possible_next_rounds(&self) -> BTreeSet<RoundId> method, which returns an empty set if there are no possible next rounds. This is a sufficient condition to tell that this round produces a result, but not a necessary one - in some protocols we may either produce a result or enter an error round, in which case the returned set won't be empty.

This is important for the chain combinator from #60, because the empty possible_next_rounds() is how it determines when the first protocol ends. We need to know this to amend possible_next_rounds() to return the first round of the second protocol, so that caching messages in a Session works correctly.

So, the problem is: how do we signal that the round produces a result, in the least intrusive way? Should we add another method to Round, may_produce_result(), with a blanket implementation (returning self.possible_next_rounds().is_empty())? Or is there some way that will better guarantee that users don't forget to implement it if their protocol behaves differently?