Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

feat: record interface #52

Merged
merged 3 commits into from
Jul 15, 2020
Merged

feat: record interface #52

merged 3 commits into from
Jul 15, 2020

Conversation

vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Jun 16, 2020

This PR adds the record-interface.

The record-interface primary goal is to guarantee that any record implementation will be compliant with the expectations of a libp2p envelope.

js-libp2p will start by having a single implementation of the record-interface, known as a peer-record. This implementations will be used to share peers' multiaddrs across the network with security guarantees, thanks to the libp2p envelope where the records will be wrapped into.

Open questions:

  • Should we have tests for the unmarshal operation in the interface tests? I think that we should have the unmarshal and then rely on isEqual to verify if the unmarshal operation resulted in the same content as before the marshal

A record implementation will now look as follows:

class PeerRecord extends Record {
  // ....
}

PeerRecord.createFromProtobuf = (buf) => {
  // ...
}

module.exports = PeerRecord

The createFromProtobuf will return an instance of the Peer Record.

References:

Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

Looks good aside from the change from isEqual to equals

src/record/README.md Outdated Show resolved Hide resolved
@vasco-santos
Copy link
Member Author

This should be ready to get merged in.
@jacobheun would you prefer this to get merged on a 0.3 branch before rolling all the releases?

@jacobheun
Copy link
Contributor

would you prefer this to get merged on a 0.3 branch

master is 0.3 and I think we're fine to move there, this is backwards compatible.

@jacobheun jacobheun merged commit 1cc943e into master Jul 15, 2020
@jacobheun jacobheun deleted the feat/record-interface branch July 15, 2020 10:29
@vasco-santos
Copy link
Member Author

lol yes, github UI shows the latest release in the git repo and not the latest 🤦‍♂️

image

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

Successfully merging this pull request may close these issues.

2 participants