Reference pstoremem components by pointer to:
1. Avoid copying locks around on construction.
2. Avoid copying these around when calling `weakClose`.
3. Ensures that they all implement the `io.Closer` interface (it's implemented
on the pointer, not the value).
Technically, we could have just taken a reference when calling `weakClose`, but
this is cleaner.
The first fix independently extends the address expiration time and the address
TTL:
By example:
* We have an address with a TTL of 4s that will expire in 1s.
* We update it with a TTL of 3s.
Before this change:
* We end up with an address with a TTL of 3s that will expire in 3s.
After this change:
* We end up with an address with a TTL of 4s that will expire in 3s.
---
The second fix prevents the in-memory addressbook from announcing existing
addresses every time their TTLs get updated.
---
The third fix correctly updates TTLs for existing addresses in the on-disk
addressbook.
This fixes https://github.com/libp2p/go-libp2p-identify/issues/2
This used to specify a max size/count but that was only because this logic was
shared between all peerstores (including the on-disk one). Now that:
1. This only applies to the in-memory one.
2. We never actually GC these.
We can just intern indefinitely.
This is a "more correct" API and we might as well fix this before it becomes
used all over the place. The new API returns ErrNoPublicKey when there is no
inlined key.
This *also* fixes a bug where the datastore-backed keystore would panic if
`ExtractPublicKey` returned `nil, nil`.
We switched to a slice to reduce the amount of memory the peerstore ended up
taking up unfortunately, this really killed us in allocations. Looking at
go-ipfs profiles, I'm worried that memory fragmentation is killing us so I'd
like to revert to the old behavior.
Note: The real solution here is dealing with "address abusers".