<commit_before>var assert = require('assert')
var Monotonic = require('monotonic').asString

// TODO Remember that the code is more complicated than the messaging. Let the
// messages absorb some of the complexity of the code. (Divide them. Restrict
// their structure.)

function Recorder (paxos) {
    var entry = paxos.log.head.body
    this.register = {
        body: {
            promise: entry.promise,
            body: entry.body,
            previous: entry.previous
        },
        previous: null
    }
    this._paxos = paxos
}

Recorder.prototype.request = function (now, request) {
    // Anything else is going to get caught synchronization and rejected.
    switch (request.method) {
    case 'prepare':
        return this._paxos._prepare(now, request)
    case 'accept':
        return { method: 'reject', promise: '0/0' }
    case 'register':
        // TODO Explain why we check the expected previous intead of doing a
        // Paxos-esque comparison.
        if (this._paxos.log.head.body.promise != request.register.body.previous) {
            return { method: 'reject', promise: '0/0' }
        }
        this.register = request.register<commit_msg>Assert message types in Recorder.<commit_after>var assert = require('assert')
var Monotonic = require('monotonic').asString

// TODO Remember that the code is more complicated than the messaging. Let the
// messages absorb some of the complexity of the code. (Divide them. Restrict
// their structure.)

function Recorder (paxos) {
    var entry = paxos.log.head.body
    this.register = {
        body: {
            promise: entry.promise,
            body: entry.body,
            previous: entry.previous
        },
        previous: null
    }
    this._paxos = paxos
}

Recorder.prototype.request = function (now, request) {
    assert(/^prepare|register$/.test(request.method), 'unexpected message to record')
    // Anything else is going to get caught synchronization and rejected.
    switch (request.method) {
    case 'prepare':
        return this._paxos._prepare(now, request)
    case 'register':
        if (this._paxos.log.head.body.promise != request.register.body.previous) {
            return { method: 'reject', promise: '0/0' }
        }
        this.register = request.register
{'fraction_non_alphanumeric': 0.10706450197455024, 'fraction_numerical': 0.0026327336551118913, 'mean_word_length': 2.523956723338485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3566054', 'n_tokens_mistral': 640, 'n_tokens_neox': 634, 'n_words': 197}