Commit Graph

45 Commits

Author SHA1 Message Date
Steven Allen
785ee8c8fd fix: handle nil peer IDs
Feels like Java all over again.

fixes #87
2020-04-05 23:05:41 -07:00
Aarsh Shah
cdec762f40 fix add addrs bug 2020-03-28 16:17:10 +05:30
Aarsh Shah
9868efd05f fix memory store signed peer record bug 2020-03-27 16:18:53 +05:30
Steven Allen
a77c7a4d61 test: check for goroutine leaks when closing the peerstore 2020-03-23 14:16:16 -07:00
Steven Allen
d1d80624c4 fix: make close work again
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.
2020-03-23 13:59:56 -07:00
Yusef Napora
59abcf549d
Certified addresses (#98) 2020-03-06 12:07:36 +00:00
Steven Allen
b4dc608f50 chore(dep): update go-log 2020-02-17 11:38:14 -05:00
Steven Allen
2fb6d7a48f fix multiple TTL bugs
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
2019-07-24 17:04:37 -07:00
Raúl Kripalani
ad0faef7c7
make RemoveProtocols take the write lock. (#90) 2019-07-10 15:45:49 +01:00
Steven Allen
491519a817 reduce allocations when adding addrs 2019-06-28 13:26:17 +02:00
Raúl Kripalani
3d3a10dd54
protobook: support removing protocols. (#84) 2019-06-19 23:53:07 +01:00
whyrusleeping
47c4411477 set map in constructor 2019-05-31 18:31:04 -07:00
Steven Allen
0b5b389640 dep: switch to core (#80)
* dep: switch to core

Specifically, remove go-libp2p-{crypto,peer} deps.

* catch a few more usages of deprecated packages.
2019-05-31 14:51:16 +01:00
Steven Allen
d2e2c56c66 feat: intern agent versions
This also starts taking up a bunch of memory after a while.
2019-05-27 14:41:29 -07:00
Steven Allen
fd3ea885ff feat: improve protocol interning
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.
2019-05-27 14:35:05 -07:00
vyzo
28b1a9f31d don't track segment sizes, it's a fruitless optimization 2019-05-17 23:39:21 +03:00
vyzo
afca355218 index the peer ID strings directly to avoid copying the byte slice 2019-05-17 23:36:46 +03:00
vyzo
d340d2983e cosmetics 2019-05-17 13:14:39 +03:00
vyzo
a9e3f07759 global interned protocol table 2019-05-17 12:47:07 +03:00
vyzo
5ed17f0b79 embed lock in segment 2019-05-17 12:37:46 +03:00
vyzo
08caa87351 refactor protocol functionality into ProtoBook 2019-05-17 12:33:33 +03:00
vyzo
303b1b6207 update segment size on gc 2019-05-09 11:20:12 +03:00
Raúl Kripalani
e7e511ba99 segment the memory peerstore; granular locks. 2019-05-09 00:27:58 +01:00
vyzo
f21f6eac4f don't eager gc 2019-04-28 16:21:07 +03:00
vyzo
c58ce1f56f add Close method to memory address book, which cancels the gc process 2019-04-28 12:19:26 +03:00
vyzo
e4cf50160f periodically schedule gc 2019-04-28 12:17:48 +03:00
vyzo
d0a3cc17f4 don't delete under the read lock
let gc clean up the addrs
2019-04-28 11:35:23 +03:00
vyzo
3cd491431b read/write metadata lock 2019-04-27 22:19:49 +03:00
vyzo
0ddad15bd2 read/write address book lock 2019-04-27 22:19:39 +03:00
Steven Allen
aae59b7403 optimize memory of in-memory peerstore 2019-04-23 00:10:05 -07:00
Adrian Lanzafame
c04ff2d27b
add keybook benchmarks
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2018-11-07 15:48:31 +10:00
Steven Allen
588ab36ce8 update to match new ExtractPublicKey API
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`.
2018-10-16 11:31:32 +01:00
Steven Allen
68a73712e1 store expiring addrs by pointer
Hopefully, this reduces the space wasted by using maps (see the comment in the
committed code).
2018-10-14 15:11:35 +01:00
Steven Allen
6daee68364
memoryAddrBook: document gc precondition 2018-10-03 17:42:54 -07:00
Steven Allen
e3a2970d93 add garbage collection for in-memory peerstore
There are better ways to do this but pausing dialing once an hour likely isn't
going to break anything and is the simplest approach.
2018-10-02 10:49:55 -07:00
Steven Allen
6d5cedf098 revert to storing peer addresses in a map
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".
2018-10-01 22:16:08 -07:00
Raúl Kripalani
1b72b920ed datastore-backed impls of KeyBook and PeerMetadata. 2018-09-28 14:04:52 +01:00
Raúl Kripalani
4e0c2169c7 Resolve TODO. 2018-09-12 13:42:26 +01:00
Raúl Kripalani
1b410c7294 Merge branch 'master' into txndatastore 2018-09-11 14:13:14 +01:00
Raúl Kripalani
1c25f160a1 normalise import aliases. 2018-09-07 18:46:23 +01:00
Raúl Kripalani
171f051aa1 add tests for keybook; []peer.ID => peer.IDSlice. 2018-09-07 13:04:14 +01:00
Raúl Kripalani
d79386365e rename NewPeerstoreWith(...) => NewPeerstore(...); adjust godoc. 2018-09-05 15:14:57 +01:00
Raúl Kripalani
bc77b649dc rename AddrMgr => AddrBook elsewhere. 2018-09-05 15:10:18 +01:00
Raúl Kripalani
7f4288fab1 rename package mem => pstoremem. 2018-09-04 18:07:44 +01:00
Raúl Kripalani
1b57c62e3d increase benchmark coverage; introduce config struct.
* benchmark caching and cacheless variants of DS addrbook.
* benchmark peers with 1, 10, 100 addrs.
2018-09-07 17:45:29 +01:00