Skip to content

Commit

Permalink
[updated statemanager from cherry picks of wip branch #1]
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-shyft committed Mar 8, 2018
1 parent 7ae5bfd commit 820eccb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/statemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,9 @@ StateManager.prototype.snapshot = function(callback) {
if (err) return callback(err);

self.snapshots.push({
blockNumber: blockNumber
blockNumber: blockNumber,
//@note: also tag the current time in this block, to restore afterwards.
currentTime: self.blockchain.currentTime()
});

self.logger.log("Saved snapshot #" + self.snapshots.length);
Expand Down Expand Up @@ -747,6 +749,10 @@ StateManager.prototype.revert = function(snapshot_id, callback) {
}, function(nextSnapshot) {
var snapshot = self.snapshots.pop();

if (typeof snapshot.currentTime !== "undefined" && snapshot.currentTime !== null) {
self.blockchain.setTime(snapshot.currentTime);
}

// For each snapshot, asynchronously pop off the blocks it represents.
async.during(function(doneWithTest) {
self.blockchain.getHeight(function(err, blockNumber) {
Expand Down

0 comments on commit 820eccb

Please sign in to comment.