Skip to content

Commit

Permalink
Use script object to create a new tree.
Browse files Browse the repository at this point in the history
See #453.
  • Loading branch information
flatheadmill committed Feb 5, 2015
1 parent f3a3087 commit 9034dd5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions strata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,8 @@ prototype(Strata, 'create', cadence(function (async) {

var locker = this.sheaf.createLocker(), count = 0, root, leaf, journal

var script = new Script(this.sheaf)

async([function () {
locker.dispose()
}], function () {
Expand All @@ -2021,13 +2023,9 @@ prototype(Strata, 'create', cadence(function (async) {
locker.unlock(leaf)
}], function () {
this.sheaf.splice(root, 0, 0, { address: leaf.address, heft: 0 })
this.sheaf.writeBranch(root, this.sheaf.filename2(root, '.replace'), async())
}, function () {
this.sheaf.rewriteLeaf(leaf, '.replace', async())
}, function () {
this.sheaf.replace(root, '.replace', async())
}, function branchReplaced () {
this.sheaf.replace(leaf, '.replace', async())
script.writeBranch(root)
script.rewriteLeaf(leaf)
script.commit(async())
})
}))

Expand Down

0 comments on commit 9034dd5

Please sign in to comment.