Skip to content

Commit

Permalink
disable legacy-replication
Browse files Browse the repository at this point in the history
  • Loading branch information
mixmix committed May 18, 2023
1 parent 61ad664 commit ffc89c4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 38 deletions.
95 changes: 57 additions & 38 deletions test/helpers/replicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { promisify: p } = require('util')
const pull = require('pull-stream')
const pullMany = require('pull-many')
const deepEqual = require('fast-deep-equal')
const { replicate } = require('scuttle-testbot')
// const { replicate } = require('scuttle-testbot')

/**
* Fully replicates person1's metafeed tree to person2 and vice versa
Expand All @@ -28,8 +28,8 @@ module.exports = async function replicate(person1, person2) {
console.log(person1.id, await p(person1.getVectorClock)())
console.log(person2.id, await p(person2.getVectorClock)())

console.error('falling back to legacyReplicate')
await legacyReplicate(person1, person2)
// console.error('falling back to legacyReplicate')
// await legacyReplicate(person1, person2)
}
}

Expand Down Expand Up @@ -95,38 +95,57 @@ async function retryUntil(checkIsDone) {
return false
}

async function legacyReplicate(person1, person2) {
await pull(
person1.metafeeds.branchStream({ old: true }),
pull.map((feedDetails) => feedDetails.id),
pull.asyncMap((feedId, cb) => {
replicate(
{
feedId,
from: person1,
to: person2,
// log: false,
},
cb
)
}),
pull.collectAsPromise()
).catch((err) => console.error('Error in legacyReplicate', err))

await pull(
person2.metafeeds.branchStream({ old: true }),
pull.map((feedDetails) => feedDetails.id),
pull.asyncMap((feedId, cb) => {
replicate(
{
feedId,
from: person2,
to: person1,
// log: false,
},
cb
)
}),
pull.collectAsPromise()
).catch((err) => console.error('Error in legacyReplicate', err))
}
/*
legacyReplicate does not work because it uses:
- ssb.createHistoryStream
- ssb-db2/compat/history-stream currently checks `ref.isFeed` on ids
passed in and BBv-1 don't pass
- can remove this
- ssb.add
- ssb-db2/compat/db uses ssb-db2/core add
- this checks for a format it can add with, but hits a problem because the
messages coming out of createHistoryStream are JSON and
`ssb-bendy-butt/format` expects "native" messages (Buffer)
*/

// async function legacyReplicate(person1, person2) {
// await pull(
// person1.metafeeds.branchStream({ old: true }),
// pull.flatten(),
// pull.map((feedDetails) => feedDetails.id),
// pull.unique(),
// pull.asyncMap((feedId, cb) => {
// console.log({feedId})
// replicate(
// {
// feedId,
// from: person1,
// to: person2,
// // log: false,
// },
// cb
// )
// }),
// pull.collectAsPromise()
// ).catch((err) => console.error('Error in legacyReplicate', err))
// console.log('here')

// await pull(
// person2.metafeeds.branchStream({ old: true }),
// pull.flatten(),
// pull.map((feedDetails) => feedDetails.id),
// pull.unique(),
// pull.asyncMap((feedId, cb) => {
// replicate(
// {
// feedId,
// from: person2,
// to: person1,
// // log: false,
// },
// cb
// )
// }),
// pull.collectAsPromise()
// ).catch((err) => console.error('Error in legacyReplicate', err))
// }
1 change: 1 addition & 0 deletions test/helpers/testbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = function createSbot(opts = {}) {
.use(require('ssb-box2'))
.use(require('ssb-db2/compat/feedstate'))
.use(require('ssb-db2/compat/ebt'))
.use(require('ssb-db2/compat/db')) // for legacy replicate
.use(require('ssb-db2/compat/history-stream')) // for legacy replicate
.use(require('ssb-ebt'))
.use(require('../..'))
Expand Down

0 comments on commit ffc89c4

Please sign in to comment.