feat: Add P2P syncing of lenses#122
Conversation
## Relevant issue(s) Resolves #4007 ## Description Tweaks the `net.Host` interface easier to consume by removing elements that require direct reference to the exact concrete type. This is required by Lens, so that a trimmed down `net.Host` interface can be consumed without making Lens dependant on Defra. The alternative is to extract `net` to a new repository - this may be desirable long term, so Lens can spin up a `net.Host` instance, but even if we go that route I'd be in favour of this change as it allows external apps to consume the interface without a direct reference. `net.Host.PeerInfo()` should now be the only interface member containing a a concrete custom type, I have left it, as this function is syntax sugar around `ID()` and `Addrs()` and is never going to be required by anything consuming the type. The Lens code may be viewed in this PR: sourcenetwork/lens#122 - see `host-go/p2p/host.go` for the re declaration of a subset of the `net.Host` interface.
c0352d2 to
997e3f8
Compare
997e3f8 to
0619ce0
Compare
fredcarle
left a comment
There was a problem hiding this comment.
LGTM. Just one minor todo before merge.
I do like our new testing frameowrk but I find myself having to relearn it everytime I review updated/new test actions lol.
| func (test *Test) Execute(t testing.TB) { | ||
| ctx := context.Background() | ||
| ctx, cancel := context.WithTimeout(ctx, 1*time.Second) | ||
| ctx, cancel := context.WithTimeout(ctx, 5*time.Second) |
There was a problem hiding this comment.
todo: Please document why 5 second is specifically important/chosen.
There was a problem hiding this comment.
:) I don't remember changing this to 5, It will probably be reverted. The tests are quick and there is nothing special about either number.
- Revert timeout
Yeah, I have that problem when working in Defra now 😅 The migration has started, and I have a branch that (mostly) updates the AddCollection action, but I was hoping to get far more done before the end of this sprint - so we can use it for the v1 testing. |
## Relevant issue(s) Resolves #4007 ## Description Tweaks the `net.Host` interface easier to consume by removing elements that require direct reference to the exact concrete type. This is required by Lens, so that a trimmed down `net.Host` interface can be consumed without making Lens dependant on Defra. The alternative is to extract `net` to a new repository - this may be desirable long term, so Lens can spin up a `net.Host` instance, but even if we go that route I'd be in favour of this change as it allows external apps to consume the interface without a direct reference. `net.Host.PeerInfo()` should now be the only interface member containing a a concrete custom type, I have left it, as this function is syntax sugar around `ID()` and `Addrs()` and is never going to be required by anything consuming the type. The Lens code may be viewed in this PR: sourcenetwork/lens#122 - see `host-go/p2p/host.go` for the re declaration of a subset of the `net.Host` interface.
Relevant issue(s)
Resolves #117
Description
Adds the ability to sync lenses over a P2P network.
Sync is done synchronously, on demand. Consumers, including Defra, will manage concurrency and timing.
As with the
StorePR, testing is very light atm due to time pressure. Testing should ideally be expanded fairly soon.