Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isUpdate filter to GetUpdates in GetGroupTangle #6

Open
Powersource opened this issue Oct 7, 2022 · 3 comments
Open

Add isUpdate filter to GetUpdates in GetGroupTangle #6

Powersource opened this issue Oct 7, 2022 · 3 comments

Comments

@Powersource
Copy link
Collaborator

Powersource commented Oct 7, 2022

See comments in this code. They used to be there in tribes1, when bringing it here i commented it out because the crut code was pretty opaque.

function GetUpdates(ssb) {
  const { seekKey } = require('bipf')
  //const { spec } = crut
  //const isUpdate = (msg) =>
  //  crut.isUpdate(getCanonicalContent(msg, spec.getTransformation))
  const B_TANGLE = Buffer.from('group')

  function tangleRoot(value) {
    return ssb.db.operators.equal(seekTangleRoot, value, {
      indexType: `value.content.tangles.group.root`,
    })
  }
  function seekTangleRoot(buffer) {
    let p = 0 // note you pass in p!
    p = seekKey(buffer, p, B_VALUE)
    if (p < 0) return
    p = seekKey(buffer, p, B_CONTENT)
    if (p < 0) return
    p = seekKey(buffer, p, B_TANGLES)
    if (p < 0) return
    p = seekKey(buffer, p, B_TANGLE)
    if (p < 0) return
    return seekKey(buffer, p, B_ROOT)
  }

  return function getUpdates(id, cb) {
    const { where, and, toPullStream } = ssb.db.operators
    pull(
      ssb.db.query(where(and(tangleRoot(id))), toPullStream()),
      //TODO: do we want this?
      //pull.filter(isUpdate),
      pull.collect(cb)
    )
  }
}
@Powersource
Copy link
Collaborator Author

cc @mixmix what magic is supposed to happen here?

@Powersource Powersource mentioned this issue Oct 7, 2022
1 task
@Powersource
Copy link
Collaborator Author

ah i guess this is a schema of some kind. to verify that all the needed fields are in the msg, like the tangles.

should check if this is actually needed anymore or if we check in other places.

should also be enough with a simple function in case we're just checking the tangle object, instead of a whole schema

@mixmix
Copy link
Member

mixmix commented Apr 20, 2023

yeah just checking the tangles[tangle].root and tangles[tangle].previous are both there are and are the right shape an all....
Because we're about to start calculating things with them. 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants