-
Notifications
You must be signed in to change notification settings - Fork 11
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
Implement trusted contacts #1406
Conversation
e7d4a92
to
2912683
Compare
9082e8f
to
e642d6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They passed the tests ,but I did a it differently that you @burdiyan said yesterday. Please see the comments below
c16c956
to
325a2d6
Compare
a884d25
to
8dbaa79
Compare
@ericvicenti looks like there're some conflicts with Electron-related files. Could you take a look? |
616eda0
to
73cca63
Compare
408a25a
to
ece39ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left my final thoughts suggesting some changes to make before merging.
f09dd40
to
213cc16
Compare
ListAccounts
should include an isTrusted boolean for each accountSetAccountTrust
with{accountId: string, isTrusted: boolean}
GetAccount
should return an isTrusted booleanListPublications
can accept a new boolean flag such asincludeGlobalPublications: true
GetPublication
accepts a new boolean flag that filters the latest version from a trusted contactDefinitions
Heads: A Change with no dependants.
Steps
get all the heads, filter out those heads that are from untrusted peers, and use that as a trusted version.
So even if a trusted head depends on a change from non-trusted peer - it's OK.
And that's where the trick is, which will be a bit hard to implement. The problem is similar for filtering out drafts (this bug: https://www.notion.so/mintter/When-I-edit-a-publication-it-becomes-a-draft-and-disappears-from-the-All-Documents-5997095f6e264b01830b0d78ae9bb6f0).
You'll get all the heads, then remove non-trusted head, but this non-trusted head may depend on changes that are trusted for you, and these may now also become heads for you in this filtered view.
But you'll be ignoring them if this is implemented naively.
E.g. to find heads now I do roughly select id from changes where id not in (select parent from change_deps). So all_changes - set_of_changes_that_have_children.
And this was what was giving troubles with drafts in the bug I linked.
So I had to change this. But it was easy for drafts, because now I just do non_draft_changes - set_of_changes_that_have_children and this will give the non draft heads.
But it's not that easy for filtering out non-trusted heads.
So it's almost like it would be easier to implement the other variant of the solution.
To summarize:
Given A(Julio) <- B(Eric) <- C(Julio) <- D(Eric) if I don't trust Eric there's 2 possible outcomes:
A is my latest trusted version.
C is my latest trusted version.
Implementing option 2 seems harder than option 1 now (I thought the opposite before).
To implement option 1:
To implement option 2:
Well now it seems like option 2 is still easier. At least easier to reason about. But it's harder to implement with pure SQL. But It's OK, maybe we should just implement it in code.
So, grab the heads, then for each head check if it's a draft, or if it's from non-trusted account. In this case, use their deps as heads, and repeat the process, until all heads in our set are trusted.
Implement option 2