mirror of https://codeberg.org/pzp/pzp-sync.git
add helper API: setFeedGoal(who,type)
This commit is contained in:
parent
fb95886055
commit
51f3f52b95
|
@ -1,5 +1,6 @@
|
||||||
const toPull = require('push-stream-to-pull-stream')
|
const toPull = require('push-stream-to-pull-stream')
|
||||||
const pull = require('pull-stream')
|
const pull = require('pull-stream')
|
||||||
|
const FeedV1 = require('ppppp-db/lib/feed-v1')
|
||||||
const makeDebug = require('debug')
|
const makeDebug = require('debug')
|
||||||
const getSeverity = require('ssb-network-errors')
|
const getSeverity = require('ssb-network-errors')
|
||||||
const Algorithm = require('./algorithm')
|
const Algorithm = require('./algorithm')
|
||||||
|
@ -67,11 +68,16 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} id
|
* @param {string} tangleId
|
||||||
* @param {Goal} goal
|
* @param {Goal} goal
|
||||||
*/
|
*/
|
||||||
function setGoal(id, goal = 'all') {
|
function setGoal(tangleId, goal = 'all') {
|
||||||
goals.set(id, goal)
|
goals.set(tangleId, goal)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setFeedGoal(author, type, goal = 'all') {
|
||||||
|
const tangleId = FeedV1.getFeedRootHash(author, type)
|
||||||
|
goals.set(tangleId, goal)
|
||||||
}
|
}
|
||||||
|
|
||||||
function initiate() {
|
function initiate() {
|
||||||
|
@ -83,6 +89,7 @@ module.exports = {
|
||||||
return {
|
return {
|
||||||
connect,
|
connect,
|
||||||
setGoal,
|
setGoal,
|
||||||
|
setFeedGoal,
|
||||||
initiate,
|
initiate,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -229,8 +229,8 @@ test('sync a feed with goal=newest but too far behind', async (t) => {
|
||||||
t.deepEquals(arr, ['m1', 'm2'], 'bob has msgs 1..2 from carol')
|
t.deepEquals(arr, ['m1', 'm2'], 'bob has msgs 1..2 from carol')
|
||||||
}
|
}
|
||||||
|
|
||||||
alice.tangleSync.setGoal(carolRootHash, 'newest-5')
|
alice.tangleSync.setFeedGoal(carolID, 'post', 'newest-5')
|
||||||
bob.tangleSync.setGoal(carolRootHash, 'newest-5')
|
bob.tangleSync.setFeedGoal(carolID, 'post', 'newest-5')
|
||||||
|
|
||||||
const remoteAlice = await p(bob.connect)(alice.getAddress())
|
const remoteAlice = await p(bob.connect)(alice.getAddress())
|
||||||
t.pass('bob connected to alice')
|
t.pass('bob connected to alice')
|
||||||
|
|
Loading…
Reference in New Issue