<commit_before>var dgram = require('dgram')

function Messenger (node, port, address) {
//object to deal with networking.
//will contain a dgram socket.
//each node will own one messenger object.
    this.node = node
    this.socket = dgram.createSocket("udp4")
    this.socket.bind(port, address)
    this.sendAcceptRequest = function () {
        for (var acceptor in node.acceptors) {
            this.socket.send(acceptReq, 0, node.acceptors[acceptor][0][0], node.acceptors[acceptor][0][1])
        }
    }
    this.sendPromise = function () {
        var promise = new Buffer(JSON.stringify({
            type: "promise",
            proposalId: node.promisedId,
            lastValue: node.lastAccepted
        }))
        this.socket.send(promise, 0, port, address)
    }
    this.sendProposal = function () {
    }
    this.sendPrepare = function () {
        var proposal = new Buffer(JSON.stringify({
            type: "prepare",
            address: node.address,
            port: node.port,
            nodeId: node.id,
            proposalId: node.proposalId
        }))
        this.sendToAcceptors(proposal)
    }
    this.sendToAcceptors = function (message) {
        for (var acceptor in this.acceptors) {
            this.socket.send(message, 0, this.acceptors[acceptor][0][0], this.acceptors[acceptors][0][1])
        }
    }
}

function Node (id, address, port, generateProposalId) { // :: Int -> Int -> Int -> Socket -> (Int) -> Node
    this.id = id
    this.address = address
    this.port = port
    this.acceptors = {} // ID -> [[port, address], last proposal]
    this.proposal = null
    this.value = null
    this.roles = []
    this.quorum = null
    this.generateProposalId = generateProposalId
    this.messenger = new Messenger(this, port, address)
}

function Cluster (nodes) { // :: [Node] -> Cluster
    this.learners = {}
    this.acceptors = {}
    this.proposers = {}<commit_msg>Cleanup copy and paste errors.<commit_after>var dgram = require('dgram')

function Messenger (node, port, address) {
//object to deal with networking.
//will contain a dgram socket.
//each node will own one messenger object.
    this.node = node
    this.socket = dgram.createSocket("udp4")
    this.socket.bind(port, address)
    this.sendAcceptRequest = function () {
        for (var acceptor in this.node.acceptors) {
            this.socket.send(acceptReq, 0, node.acceptors[acceptor][0][0], node.acceptors[acceptor][0][1])
        }
    }
    this.sendPromise = function () {
        var promise = new Buffer(JSON.stringify({
            type: "promise",
            proposalId: this.node.promisedId,
            lastValue: this.node.lastAccepted
        }))
        this.socket.send(promise, 0, port, address)
    }
    this.sendProposal = function () {
    }
    this.sendPrepare = function () {
        var proposal = new Buffer(JSON.stringify({
            type: "prepare",
            address: this.node.address,
            port: this.node.port,
            nodeId: this.node.id,
            proposalId: this.node.proposalId
        }))
        this.sendToAcceptors(proposal)
    }
    this.sendToAcceptors = function (message) {
        for (var acceptor in this.node.acceptors) {
            this.socket.send(message, 0, this.acceptors[acceptor][0][0], this.acceptors[acceptors][0][1])
        }
    }
}

function Node (id, address, port, generateProposalId) { // :: Int -> Int -> Int -> Socket -> (Int) -> Node
    this.id = id
    this.address = address
    this.port = port
    this.acceptors = {} // ID -> [[port, address], last proposal]
    this.proposal = null
    this.value = null
    this.roles = []
    this.quorum = null
    this.generateProposalId = generateProposalId
    this.messenger = new Messenger(this, port, address)
}

function Cluster (nodes) { // :: [Node] -> Cluster
    this.learners = {}
    this.acceptors = {}
    this.proposers = {}
{'fraction_non_alphanumeric': 0.13222079589216945, 'fraction_numerical': 0.0061617458279845955, 'mean_word_length': 2.3644214162348876, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6448052', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1175, 'n_words': 274}