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
//! Defines the [`Tracer`] trait.

use crate::invocation::CoordNumOf;
use crate::invocation::Invocation;
use crate::invocation::LogEntryIdOf;
use crate::invocation::RoundNumOf;

/// Records events as they are observed by a node.
///
/// Tracing events isn't useful under normal operation. It can aid in
/// understanding when and how inconsistencies were introduced. As such, some
/// tests set a tracer so that they can emit a trace if they fail.
///
/// See [`NodeBuilder::traced_by`][crate::NodeBuilder::traced_by].
pub trait Tracer<I: Invocation>: Send {
    /// A promise was made.
    fn record_promise(
        &mut self,
        round_num: RoundNumOf<I>,
        coord_num: CoordNumOf<I>,
        promise: Vec<(RoundNumOf<I>, CoordNumOf<I>, LogEntryIdOf<I>)>,
    );

    /// A proposal was accepted.
    fn record_accept(
        &mut self,
        round_num: RoundNumOf<I>,
        coord_num: CoordNumOf<I>,
        log_entry_id: LogEntryIdOf<I>,
    );

    /// A log entry was committed.
    fn record_commit(&mut self, round_num: RoundNumOf<I>, log_entry_id: LogEntryIdOf<I>);
}