Exemplo n.º 1
0
  feed.finalize(function () {
    var clone = core2.createFeed(feed.key, {storage: ram()})
    var missing = 1000

    replicate(clone, feed)

    clone.on('download', function (block) {
      if (missing === 1000) t.same(clone.blocks, 1000, 'should be 1000 blocks')
      if (block >= 1000) t.fail('unknown block')
      if (!--missing) t.end()
    })
  })
Exemplo n.º 2
0
var storage = multi(function (offset, cb) {
  console.log('opening', offset)
  for (var i = 0; i < list.length; i++) {
    if (list[i] > offset) {
      cb(null, {
        start: list[i - 1] || 0,
        end: list[i],
        storage: ram()
      })
      return
    }
  }
})
Exemplo n.º 3
0
tape('replicate non live, bigger with external storage', function (t) {
  var core1 = hypercore()
  var core2 = hypercore()

  var feed = core1.createFeed({live: false, storage: ram()})

  for (var i = 0; i < 1000; i++) {
    feed.append('#' + i)
  }

  feed.finalize(function () {
    var clone = core2.createFeed(feed.key, {storage: ram()})
    var missing = 1000

    replicate(clone, feed)

    clone.on('download', function (block) {
      if (missing === 1000) t.same(clone.blocks, 1000, 'should be 1000 blocks')
      if (block >= 1000) t.fail('unknown block')
      if (!--missing) t.end()
    })
  })
})
Exemplo n.º 4
0
 function create (name) {
   create[name] = ram()
   return create[name]
 }