Permalink
Browse files

remove dead code

  • Loading branch information...
1 parent 0ac5a30 commit ba25ad4fbf55b58250cb29d70e8828d832be9a3c @dominictarr committed Feb 13, 2013
Showing with 0 additions and 104 deletions.
  1. +0 −104 index.js
View
104 index.js
@@ -128,110 +128,6 @@ module.exports = function (db, id, schema) {
db.scuttlebutt.view = opener.view
db.scuttlebutt.createRemoteStream = MakeCreateStream(opener) //dbO.createStream
- /*
- db.scuttlebutt._open =
- opener.open = function (doc_id, tail, callback) {
- if('function' === typeof tail) callback = tail, tail = true
-
- if(!doc_id) throw new Error('must provide a doc_id')
- var emitter
- if('string' === typeof doc_id) {
- emitter = match(doc_id)
- if(!emitter) {
- var err = new Error('no schema for:' + doc_id)
- if(callback) return callback(err)
- throw err
- }
- }
- else {
- //okay, in the case that this scuttlebutt has changes that arn't in the database,
- //just save the whole history?
- //generally, I will not be resaving documents... so it's unlikely that a fresh scuttlebutt
- //will have changes - need to handle this case to be correct though...
- //so, just write the whole history as a single batch?
-
- //there are two options... write the db to the scuttlebutt,
- //or write the scuttlebutt to the db.
-
- //okay, so it's gonna be: write the db to the scuttlebutt...
- emitter = doc_id
- doc_id = emitter.name
- }
-
- if(emitter.setId) emitter.setId(id)
- else emitter.id = id
-
- //if we are counting streams to know when to disconnect,
- //but we want to keep this instance alive while we are disconnected,
- //we'll need to track this a different way...
- //it would be better to not count the 'HOME' stream,
- //and then dispose when the clone streams get it 0.
- emitter._streams ++
-
- //read current state from db.
- var opts = bucket.range([doc_id, 0, true], [doc_id, '\xff', true])
- opts.tail = tail
-
- var stream =
- db.liveStream(opts)
- .on('data', function (data) {
- //ignore deletes,
- //deletes must be an update.
- if(data.type == 'del') return
-
- var ary = bucket.parse(data.key).key
- var ts = Number(ary[1])
- var source = ary[2]
- var change = JSON.parse(data.value)
-
- checkOld(source, ts)
-
- emitter._update([change, ts, source])
- })
-
- //this scuttlebutt instance is up to date with the db.
-
- var ready = false
- function onReady () {
- if(ready) return
- ready = true
- emitter.emit('sync')
- if(callback) callback(null, emitter)
- }
-
- stream.once('sync', onReady)
- stream.once('end' , onReady)
-
- emitter.once('dispose', function () {
- stream.destroy()
- })
-
- //write the update twice,
- //the first time, to store the document.
- //maybe change scuttlebutt so that value is always a string?
- //If i write a bunch of batches, will they come out in order?
- //because I think updates are expected in order, or it will break.
-
- function onUpdate (update) {
- var value = update[0], ts = update[1], id = update[2]
- insertBatch (id, doc_id, ts, JSON.stringify(value))
- }
-
- emitter.history().forEach(onUpdate)
-
- //track updates...
- emitter.on('_update', onUpdate)
-
- //an update is now no longer significant
- emitter.on('_remove', function (update) {
- var ts = update[1], id = update[2]
- deleteBatch (id, doc_id, ts)
- })
-
- return emitter
- }
- //*/
-
db.scuttlebutt.createReplicateStream = function (opts) {
opts = opts || {}
var yourClock, myClock

0 comments on commit ba25ad4

Please sign in to comment.