ssbc / ssb-friends

Manages the SSB social graph
MIT License
23 stars 6 forks source link

Unbermuda #67

Closed staltz closed 3 years ago

staltz commented 3 years ago
staltz commented 3 years ago

@arj03 (and @mixmix !) This PR isn't ready for review, but it's ready for some high-level feedback.

I'm changing ssb-friends to add/remove the APIs:

-onEdge
 follow
 block
 isFollowing
 isBlocking
 hops
 hopStream
+graph
+graphStream
-get
-createFriendStream
-stream
 help

The main difference is that I added graph & graphStream which are similar to (respectively) hops & hopStream, but graph gives us just the "edges" of the social graph, whereas hops gives us the "distances" to all nodes from the perspective of a center node. Might sound similar but it's very different. We need graph so that Alice can discover that Bob blocks Carol, we cannot infer that directly from hops data.

The new graph & graphStream is very similar to the legacy (respectively) get & stream, but those were "legacy" APIs just in the sense that they use true for following, false for blocking, and null for neutral. graph & graphStream use 1, -1, and -2, similar to other modern APIs in ssb-friends.

I'm already using ssb.friends.graphStream in ssb-replication-scheduler to get all edges of the social graph and update ssb-ebt. Check its index.js, the module is actually quite simple and small.

staltz commented 3 years ago

I do not know why this module should host auth-glue - that seems like connection domain (ie put this in ssb-conn?) thinking?

@mixmix Very interesting that you spotted that. Arj and I came to the same conclusion, and I started building ssb-conn-firewall which will handle this and more cases.

What's nice is that this PR made it easier for you to have this insight. Before, it was confusingly mixed with all the rest.

But I'll remove auth-glue.js in another PR. This PR is about untangling replication concerns out of ssb-friends, that's the definition of done for the unbermuda project, shouldn't include the auth-glue.js. But I'll do that soonish, maybe next week.

staltz commented 3 years ago

@mixmix and @arj03 I addressed most of your comments :)

mixmix commented 3 years ago

Cool

On Sun, 27 Jun 2021, 00:03 Anders Rune Jensen, @.***> wrote:

@.**** commented on this pull request.

In index.js https://github.com/ssbc/ssb-friends/pull/67#discussion_r659159955:

  • const unsubscribe = layered.onEdge((source, dest, value) => {
  • p.push({ source, dest, value })
  • })
  • const p = Pushable(unsubscribe)
  • if (old) {
  • p.push(layered.getGraph())
  • }
  • cb(null, p)
  • })
  • })
  • } else {
  • return pCont((cb) => {
  • onReady(() => {
  • cb(null, pull.once(layered.getGraph()))
  • })
  • })

Being a tie breaker feels like a big responsibility. From my point of view I think it makes sense for the API to have similar structure even if some cases are rarely used. It is important that the default options are good, which they are, so I'm in favor of keeping it the way it is.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ssbc/ssb-friends/pull/67#discussion_r659159955, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUK3HTL6DTIBX6PDPF6YTLTUW6ZXANCNFSM46XAHDZQ .

staltz commented 3 years ago

Can I get some thumbs ups to merge this and release version ssb-friends@5.0.0?