hamok
Version:
Lightweight Distributed Object Storage on RAFT consensus algorithm
35 lines (34 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RaftVoteResponse = exports.RaftVoteRequest = void 0;
class RaftVoteRequest {
term;
lastLogIndex;
lastLogTerm;
peerId; // destination endpoint id
candidateId; // source endpoint id
constructor(term, lastLogIndex, lastLogTerm, peerId, candidateId) {
this.term = term;
this.lastLogIndex = lastLogIndex;
this.lastLogTerm = lastLogTerm;
this.peerId = peerId;
this.candidateId = candidateId;
}
createResponse(voteGranted) {
return new RaftVoteResponse(this.term, voteGranted, this.candidateId, this.peerId);
}
}
exports.RaftVoteRequest = RaftVoteRequest;
class RaftVoteResponse {
term;
voteGranted;
destinationPeerId;
sourcePeerId;
constructor(term, voteGranted, destinationPeerId, sourcePeerId) {
this.term = term;
this.voteGranted = voteGranted;
this.destinationPeerId = destinationPeerId;
this.sourcePeerId = sourcePeerId;
}
}
exports.RaftVoteResponse = RaftVoteResponse;