- this.strategyTree = Preconditions.checkNotNull(resolver);
- this.rootNode = ModifiedNode.createUnmodified(snapshot.getRootNode());
+ this.strategyTree = Preconditions.checkNotNull(resolver).snapshot();
+ this.rootNode = ModifiedNode.createUnmodified(snapshot.getRootNode(), false);
+
+ /*
+ * We could allocate version beforehand, since Version contract
+ * states two allocated version must be always different.
+ *
+ * Preallocating version simplifies scenarios such as
+ * chaining of modifications, since version for particular
+ * node in modification and in data tree (if successfully
+ * committed) will be same and will not change.
+ */
+ this.version = snapshot.getRootNode().getSubtreeVersion().next();