Skip to content

Commit

Permalink
Convert branch split to use script object.
Browse files Browse the repository at this point in the history
Closes #453.
  • Loading branch information
flatheadmill committed Feb 5, 2015
1 parent 9034dd5 commit 72838f7
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions strata.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ prototype(Sheaf, 'splitLeaf', cadence(function (async, address, key, ghosts) {

prototype(Sheaf, 'splitBranchAndUnlock', cadence(function (async, address, key) {
var locker = this.createLocker(),
script = new Script(this),
descents = [],
children = [],
encached = [],
Expand Down Expand Up @@ -1003,21 +1004,13 @@ prototype(Sheaf, 'splitBranchAndUnlock', cadence(function (async, address, key)

this.splice(page, 0, 0, cut)
}
}, function () {

children.unshift(full.page)
async.forEach(function (page) {
this.writeBranch(page, this.filename2(page, '.replace'), async())
})(children)
}, function () {
this.writeBranch(parent.page, this.filename2(parent.page, '.pending'), async())
}, function () {
this._rename(parent.page, 0, '.pending', '.commit', async())
}, function () {
async.forEach(function (page) {
this.replace(page, '.replace', async())
})(children)
}, function () {
this.replace(parent.page, '.commit', async())
children.forEach(function (page) {
script.writeBranch(page)
})
script.writeBranch(parent.page)
script.commit(async())
}, function () {
return [ parent.page, key ]
})
Expand Down

0 comments on commit 72838f7

Please sign in to comment.