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

[DO NOT MERGE] Sketch of fix for #268 #737

Closed
wants to merge 7 commits into from
Closed

Conversation

EvanHahn
Copy link
Contributor

@EvanHahn EvanHahn commented Jul 30, 2024

I recommend reviewing this with whitespace changes disabled.

I'm unsure of the right approach for #268. This incomplete PR sketches out what I think it should look like.

*This is a types-only change.*

Before this change, we used `any` for a Hypercore peer's type.

After this change, we use a new type, `HypercorePeer`, designed to match
[Hypercore's `Peer` class][0].

Ideally, we would put this in `@digidem/types` or DefinitelyTyped. For
now, I think this is an improvement over the `any`s we currently use.

I did this because I'm working with peer-related code and found the
`any`s difficult to work with.

[0]: https://github.com/holepunchto/hypercore/blob/de993dc051301f03570df0eb7929c06286745563/lib/replicator.js#L331
// not yet synced role records.
return NO_ROLE
}
async getRole(deviceId, options = {}) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to add new behavior to Roles, as I felt it was a clean place to put it. Let me know if that seems wrong.

@gmaclennan
Copy link
Member

The original issue is about keys that are being sent to peers, where-as this sketch seems to be focussed on what to do with keys that are received. E.g. we don't want to send the hypercore keys for anything other than the auth cores unless we actually validate that a peer is part of a project.

Currently as long as a peer has the project key, we send keys for all cores. We also send "haves".

We want to change behaviour so that only auth core keys are sent to peers that have the project key, and then only send keys for cores in other namespaces once we evaluate whether that peer is authorized to sync that namespace. Similarly with sending "haves". This means that we need to check the capabilities and roles before sending this data, and we also need to listen for updates to capabilities and roles, because as auth cores sync, this data can update/change.

Did you see the draft PR for this https://github.com/digidem/mapeo-core-next/pull/390/files? I think that is roughly a reasonable approach, but there are probably a few errors in it and I don't think tests were actually passing.

Base automatically changed from hypercorepeer-type to main August 16, 2024 15:49
@EvanHahn
Copy link
Contributor Author

Closing because we don't intend to incorporate this.

@EvanHahn EvanHahn closed this Aug 25, 2024
@EvanHahn EvanHahn deleted the 2024-07-30-evanhahn/268 branch August 25, 2024 15:32
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

Successfully merging this pull request may close these issues.

2 participants