ssbc / ssb-ooo

retrive ssb messages Out Of Order

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get({ meta: true }) not working for a message

christianbundy opened this issue · comments

I must be doing something wrong, but I'm getting the same behavior in both JS and the CLI:

$ ssb-server get --meta true --id '%jVcSjZvpRfer21sAJYXa6QDdTwHUZe1ySHWYjlXEZ8E=.sha256'
{
  "key": "%jVcSjZvpRfer21sAJYXa6QDdTwHUZe1ySHWYjlXEZ8E=.sha256",
  "value": {
    "previous": "%bECdgduptaoBYMzoUo7nZOnXEEz2QmaoNkUjtvsnlA8=.sha256",
    "author": "@utAtSqQlzvd3qWlxZNZPbLb5H3PcqKvZaNVWtTsHG6c=.ed25519",
    "sequence": 38,
    "timestamp": 1565173757300,
    "hash": "sha256",
    "content": {
      "text": "I guess the pub I joined previously was offline at that time and manyverse were not syncing . Later when I joined another pub sync started and now all seems fine.",
      "type": "post",
      "root": "%1AWnWNJZ/ydzjMtI2igbkKGUzOFrb3wRIhIGXCHtWFc=.sha256",
      "mentions": []
    },
    "signature": "s7TYgUx5g7h4xgIvDOfM6HI0Ly5yuRdHZb28LKTA39TRL3n0ZoRDjj1kTj3XGUlL5R7vd8X+8GM44eOb2AirAw==.sig.ed25519"
  },
  "timestamp": 1565189023033.003
}
$ ssb-server get --meta true --id '%8jU/AOwwGFuy/41M/2jVFaPE/UI6IIa/v3DS7h4KPZk=.sha256'
{
  "previous": "%D2Tjdyk66mhWJJ5KqAqf8NHOGLsy1j1rTpsNqRR8OBU=.sha256",
  "sequence": 48,
  "author": "@Ej6R4epgybFHqPZnT/uRdQ9Iw2zV1rUVHbUjYA3sJA4=.ed25519",
  "timestamp": 1565118910946,
  "hash": "sha256",
  "content": {
    "type": "post",
    "channel": "new-people",
    "text": "Greetings. Looking to connect with those heavily involved in #decentralized platforms and modes of exchange, #cryptocurrency in particular. \nStrong interest in #alternativeenergy (especially #solarpower), #privacy, #privacytech, #cryptography and #security.",
    "mentions": [
      {
        "link": "#decentralized"
      },
      {
        "link": "#cryptocurrency"
      },
      {
        "link": "#alternativeenergy"
      },
      {
        "link": "#solarpower"
      },
      {
        "link": "#privacy"
      },
      {
        "link": "#privacytech"
      },
      {
        "link": "#cryptography"
      },
      {
        "link": "#security"
      }
    ]
  },
  "signature": "5nkBkK6Fnbu118Sxxi4IbhwMT7fZ6tuyUKUWFJ2POOqPpCNhCyo4QHWcY7KCSHLVIZjfBIXj6uu/ms001TClAw==.sig.ed25519"
}

On most messages the meta option ensures that I receive the object as { key, value }, but for some reason this message seems to be getting passed as if the meta option was disabled. Anyone have ideas why this might be?

I can confirm that ssb-db's get() is working correctly and passing the full message with metadata. Maybe something is happening in muxrpc? I'm going to move this to ssb-server.

@dominictarr @mixmix @staltz @arj03

Any chance any of you have seen this? I have to throw out a handful of messages because of this bug and I'm having a really hard time pinning down where it's losing { key }.

REPRODUCED! It looks like ssb-ooo replaces ssbDb.get() with a function that doesn't respect the { meta } option.

SSB-DB: Message not found

Input

const secretStack = require('secret-stack')
const ssbCaps = require('ssb-caps')
const ssbDb = require('ssb-db')

const initialConfig = {
  caps: ssbCaps,
  path: '/home/christianbundy/.ssb/'
}

const stack = secretStack(initialConfig).use(ssbDb)
const messageKey = '%I/vlF/w18anHGRox3SgxrTiG9zrSdjHAImz6vwIhyZE=.sha256'

const app = stack({})

app.get({ id: messageKey, meta: true }, (err, value) => {
  if (err) throw err 
  console.log(value)
  app.close()
})

Output

/home/christianbundy/src/flotilla/node_modules/level-packager/node_modules/levelup/lib/levelup.js:192
        err = new NotFoundError('Key not found in database [' + key + ']', err)
              ^
NotFoundError: Key not found in database [%I/vlF/w18anHGRox3SgxrTiG9zrSdjHAImz6vwIhyZE=.sha256]
    at /home/christianbundy/src/flotilla/node_modules/level-packager/node_modules/levelup/lib/levelup.js:192:15
    at /home/christianbundy/src/flotilla/node_modules/encoding-down/index.js:75:21

shell returned 1

SSB-DB + SSB-OOO: Message without key

Input

const secretStack = require('secret-stack')
const ssbCaps = require('ssb-caps')
const ssbDb = require('ssb-db')

const initialConfig = {
  caps: ssbCaps,
  path: '/home/christianbundy/.ssb/'
}

const stack = secretStack(initialConfig)
  .use(ssbDb)
  .use(require('ssb-ooo'))

const messageKey = '%I/vlF/w18anHGRox3SgxrTiG9zrSdjHAImz6vwIhyZE=.sha256'

const app = stack({})

app.get({ id: messageKey, meta: true }, (err, value) => {
  if (err) throw err
  console.log(value)
  app.close()
})

Output

{ previous: '%vB7cU50Xlu6lZ9TwHvUBlJqJrSbH1+UVkZ7sqv50wxU=.sha256',
  sequence: 10,
  author: '@4nh94nAjLIV42+6RcNhEecVU0mXmGDOSFq49tZUYGVg=.ed25519',
  timestamp: 1576151631387,
  hash: 'sha256',
  content:
   { type: 'post',
     root: '%50uBB9Bh17wZK2vpNqGbokBqP5RDDD1/FATUxCb3eW0=.sha256',
     branch: '%50uBB9Bh17wZK2vpNqGbokBqP5RDDD1/FATUxCb3eW0=.sha256',
     reply:
      { '%50uBB9Bh17wZK2vpNqGbokBqP5RDDD1/FATUxCb3eW0=.sha256': '@A+NcCwRM0oFkZncytGDjD6dpX/KcxHAehvaq2vwy66c=.ed25519' },
     channel: 'scuttlebutt',
     recps: null,
     text:
      'Being security minded I was thinking about this as well: How can this system be secured against illegal or unintended use? Is it up to the "public" server moderators to prevent this, and are there any tools to assist with the moderation of such content? If so, does this mean that SB will eventually move to purely private servers?  Any p2p system very quickly can fall into disarray and be used for both illegal content and spam. How do you moderate? I haven\'t yet seen a p2p system that hasn\'t eventually fallen into that... but I\'d be interested to hear ideas on how to prevent this from happening here.\n\nThe internet as a whole is a terrible place full of terrible people, and as soon as you hit the critical mass of popularity, you have to have security and controls, otherwise you quickly fall prey to first the spammers, and then later much worse things.',
     mentions: [] },
  signature:
   'mwZNq0eXRosIUOHGliR/WJwN1IgPE0aIcfPfPtXn+HA5Mybc/NUlMrT/zEWMKs0WchdMjBXXAYVYXjlvV5J4Aw==.sig.ed25519' }