Object.defineProperty(exports, "__esModule", { value: true });
const levelup = require("levelup");
const leveldown = require("leveldown");
const LogServer_1 = require("./LogServer");
class LevelDBLogServer extends LogServer_1.LogServer {
    constructor() {
        super();
        this.db = levelup(leveldown("./mydb"));
    }
    storeLog(log) {
        this.db.put(log.index.toString(), JSON.stringify(log), function (err) {
            if (err)
                return console.log("Ooops! (put)", err); // some kind of I/O error
        });
    }
    getLog(index, fn) {
        this.db.get(index.toString(), function (err, value) {
            if (err) {
                console.log("leveldb get err", err);
                fn(err, null);
                return;
            }
            value = JSON.parse(value.toString());
            fn(null, value);
        });
    }
}
exports.default = LevelDBLogServer;
//# sourceMappingURL=LevelDBLogServer.js.map