Skip to content

Commit

Permalink
Use equal in get root msg
Browse files Browse the repository at this point in the history
  • Loading branch information
Powersource committed Oct 23, 2023
1 parent 1d3a762 commit 3425b27
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/epochs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
isDecrypted,
toPullStream,
} = require('ssb-db2/operators')
const { seekKey } = require('ssb-db2/seekers')
const {
validator: {
group: {
Expand All @@ -36,7 +37,7 @@ const isSubsetOf = require('set.prototype.issubsetof')
const { groupRecp } = require('./operators')
const getTangleUpdates = require('./tangles/get-tangle-updates')
const pullMany = require('pull-many')
const { slowEqual } = require('jitdb/operators')
const { equal } = require('jitdb/operators')

const msgPattern = toPattern(new Butt64('ssb:message/[a-zA-Z0-9-]+/', null, 32))
const feedPattern = toPattern(new Butt64('ssb:feed/[a-zA-Z0-9-]+/', null, 32))
Expand Down Expand Up @@ -522,14 +523,16 @@ function epochNodeStream(ssb, groupId, opts = {}) {
}

function getRootVal(ssb, msgId, cb) {
//console.log('msgId', msgId)
pull(
pullMany([
ssb.db.query(
where(
and(
isDecrypted('box2'),
slowEqual('key', toMessageSigil(msgId), { prefix: true })
equal(seekKey, toMessageSigil(msgId), {
indexType: 'groupRootMsgId',
prefix: true,
})
)
),
live({ old: true }),
Expand All @@ -540,8 +543,6 @@ function getRootVal(ssb, msgId, cb) {
pull.filter((msg) => fromMessageSigil(msg.key) === msgId)
),
]),
//pull.through((msg) => console.log('about to filter', msg)),
//pull.filter((msg) => fromMessageSigil(msg.key) === msgId),
pull.take(1),
pull.drain(
(msg) => cb(null, msg.value),
Expand Down

0 comments on commit 3425b27

Please sign in to comment.