Object.defineProperty(exports, "__esModule", { value: true });
const OperationLog_1 = require("../helperFunctions/OperationLog");
const LogServer_1 = require("./LogServer");
class InMemoryLogServer extends LogServer_1.LogServer {
    constructor(locStore) {
        super(locStore);
        this._storedLogs = {};
    }
    storeLog(log) {
        this._storedLogs[log.index] = log;
    }
    storeLogs(logs, callback = function () { }) {
        logs.forEach(log => this.storeLog(log));
        callback();
    }
    getLog(index, fn) {
        var log = this._storedLogs[index];
        if (!log) {
            fn(Error("log not found, index is: " + index), null);
            return;
        }
        // deep clone log so we can modify it without affecting the original
        // possibly slow, can fix later
        log = new OperationLog_1.default(JSON.parse(JSON.stringify(log)));
        fn(null, log);
    }
}
exports.default = InMemoryLogServer;
//# sourceMappingURL=InMemoryLogServer.js.map