Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
check if checkpointed before delete
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderer committed Dec 10, 2014
1 parent 1522edf commit 1546716
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ internals.Trie.prototype.get = function (key, cb) {
* @param {Buffer|String} Value
*/
internals.Trie.prototype.put = function (key, value, cb) {

var self = this;

if (value === '') {
Expand Down Expand Up @@ -593,7 +594,7 @@ internals.Trie.prototype._formatNode = function (node, topLevel, remove, opStack
var rlpNode = node.serialize();
if (rlpNode.length >= 32 || topLevel) {
var hashRoot = node.hash();
if (remove) {
if (remove && !this.isCheckpoint) {
opStack.push({
type: 'del',
key: hashRoot
Expand Down Expand Up @@ -651,15 +652,10 @@ internals.Trie.prototype.createReadStream = function () {
};

//creates a checkpoint
internals.Trie.prototype.checkpoint = function (cb) {
internals.Trie.prototype.checkpoint = function() {
var self = this;
cb = internals.together(cb, self.sem.leave);

self.sem.take(function () {
self._checkpoints.push(self.root);
self.isCheckpoint = true;
cb();
});
self._checkpoints.push(self.root);
self.isCheckpoint = true;
};

//commits a checkpoint.
Expand Down

0 comments on commit 1546716

Please sign in to comment.