fn handle_response()

in librabft-v2/src/data_sync.rs [209:240]


    fn handle_response(
        &mut self,
        smr_context: &mut Context,
        response: Self::Response,
        clock: NodeTime,
    ) -> Async<()> {
        let num_records = response.records.len();
        // Insert all the records in order.
        // Process the commits so that new epochs are created along the way.
        // No need to call a full handler `update_node` because past epochs are stopped.
        for (i, (epoch_id, records)) in response.records.into_iter().enumerate() {
            if epoch_id < self.epoch_id() {
                // Looks like we have stopped this epoch in the meantime.
                continue;
            }
            if epoch_id > self.epoch_id() {
                // This should not happen. Abort.
                break;
            }
            for record in records {
                self.insert_network_record(epoch_id, record, smr_context);
            }
            if i == num_records - 1 {
                // Leave the latest epoch for the main handler to process.
                break;
            }
            // Deliver commits and start the next epochs.
            self.process_commits(smr_context);
            self.update_tracker(clock);
        }
        Box::pin(future::ready(()))
    }