UNPKG

deth

Version:

Ethereum node focused on Developer Experience

31 lines (30 loc) 639 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class CheckpointMap { constructor(state = {}) { this.state = state; this.checkpoints = []; } checkpoint() { this.checkpoints.push(this.state); } revert() { this.state = this.checkpoints.pop(); } commit() { this.checkpoints.pop(); } get(k) { return this.state[k]; } set(k, v) { this.state = { ...this.state, [k]: v, }; } copy() { return new CheckpointMap(this.state); } } exports.CheckpointMap = CheckpointMap;