Created
June 10, 2013 11:39
-
-
Save dominictarr/5748161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var level = require('level') | |
var sublevel = require('sublevel') | |
var db = sublevel(level(path)) | |
var Merkle = require('level-merkle') | |
var treeDb = Merkle(db, 'merkle') | |
treeDb.topHash(function (err, hash) { | |
//get the top hash | |
}) | |
var ts = treeDb.createTreeStream() //stream the hashes from the top to the leaves | |
var ts2 = tree2Db.createTreeStream() | |
//extract the difference between two trees? | |
var ms = Merkle.difference(ts, ts2) | |
//retrive the differences so you can send them | |
//pull(a,b,c) is the same as a.pipe(b).pipe(c) | |
//in the new pull streams. | |
pull( | |
ms, | |
pull.asyncMap(function (hash, cb) { | |
treeDb.get(hash, cb) | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment