Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

expose db opener for testing

  • Loading branch information...
commit a7a9f062589817fdff259f7950a372021378af78 1 parent f9e2b91
@dominictarr authored
Showing with 3 additions and 29 deletions.
  1. +1 −27 index.js
  2. +2 −2 test/reopen.js
View
28 index.js
@@ -9,12 +9,6 @@ var LiveStream = require('level-live-stream')
var REDIS = require('redis-protocol-stream')
var makeSchema = require('./lib/schema')
-//var cache = require('./lib/cache')
-//var sbMapReduce = require('./lib/map')
-
-//var Remote = require('./remote')
-
-//var DbOpener = require('./lib/db-opener')
var BufferedOpener
= require('./lib/buffered-opener')
var ClientOpener = require('./lib/client-opener')
@@ -36,14 +30,6 @@ module.exports = function (db, id, schema) {
var replicateDb = db.sublevel('replicate')
var vectorDb = db.sublevel('vector')
-/*
- var prefix = DEFAULT //TEMP
- var bucket = Bucket(prefix || DEFAULT)
- var _bucket = Bucket((prefix || DEFAULT)+'_R')
- var vector = Bucket((prefix || DEFAULT)+'_V')
- var range = bucket.range()
-*/
-
var sources = {}
if('string' !== typeof id)
@@ -51,10 +37,6 @@ module.exports = function (db, id, schema) {
id = id || uuid()
-// if(db.scuttlebutt) return db
-
-// hooks()(db)
-
var match = makeSchema(schema, id)
//create a new scuttlebutt attachment.
@@ -86,10 +68,6 @@ module.exports = function (db, id, schema) {
return db.scuttlebutt.open.apply(null, args)
}
- db.scuttlebutt._checkOld = checkOld
- db.scuttlebutt._match = match
- db.scuttlebutt._localDb = localDb
- db.scuttlebutt._sep = sep
function key() {
return [].slice.call(arguments).join(sep)
}
@@ -164,11 +142,6 @@ module.exports = function (db, id, schema) {
doc_id = emitter.name
}
-
- //read current state from db.
-// var opts = bucket.range([doc_id, 0, true], [doc_id, '\xff', true])
- // opts.tail = tail
-
var stream = LiveStream(localDb, {
start: [doc_id, 0].join(sep),
end: [doc_id, '~'].join(sep)
@@ -281,6 +254,7 @@ module.exports = function (db, id, schema) {
var opener = BufferedOpener(schema, id).swap(dbO)
db.scuttlebutt.open = opener.open
+ db.scuttlebutt._opener = dbO
db.scuttlebutt.view = opener.view
db.scuttlebutt.createRemoteStream = MakeCreateStream(opener) //dbO.createStream
View
4 test/reopen.js
@@ -5,7 +5,7 @@ var SubLevel = require('level-sublevel')
var rimraf = require('rimraf')
var delay = require('delay-stream')
var Model = require('scuttlebutt/model')
-var Opener = require('../lib/db-opener')
+//var Opener = require('../lib/db-opener')
function create(path, cb) {
rimraf(path, function (err) {
@@ -35,7 +35,7 @@ create('/tmp/level-scuttlebutt-test-A', function (err, db) {
m.set('y', Math.random())
m.set('z', Math.random())
- var opener = Opener(db)
+ var opener = db.scuttlebutt._opener //Opener(db)
opener.open(m, function () {
console.log('reopened')
Please sign in to comment.
Something went wrong with that request. Please try again.