Commit Graph

71 Commits

Author SHA1 Message Date
Marco Munizaga
143e7c94ab Use a clock interface to better support testing 2022-05-25 15:39:56 -07:00
Leo Balduf
e9c56d257b
pstoremem: fix slice preallocation in GetProtocols (#198) 2022-04-21 05:29:45 -07:00
Marten Seemann
c583a9b966
Merge pull request #194 from libp2p/remove-validate
remove all calls to peer.ID.Validate
2022-01-02 23:41:42 -08:00
Marten Seemann
005ad81f7e remove all calls to peer.ID.Validate 2021-12-19 16:04:37 +04:00
Marten Seemann
05c606eb46 move AddrList to pstoremen, unexport it 2021-12-19 15:51:38 +04:00
Marten Seemann
e4d9dbb9c8
Merge pull request #191 from libp2p/various-addr-book-optimizations
optimize allocations in the memory address book
2021-12-14 19:17:53 +04:00
Marten Seemann
03b957ffbb implement a clean shutdown for the memory address book 2021-12-14 19:04:57 +04:00
Marten Seemann
6ca4389e18 optimize map lookup when adding addresses 2021-12-14 18:58:51 +04:00
Marten Seemann
8354ce4655 remove unnecessary map allocation when adding addresses 2021-12-14 18:56:28 +04:00
Marten Seemann
4ff41e6ed1 avoid unnecessary allocation when gc'ing the addrbook 2021-12-14 18:51:40 +04:00
Marten Seemann
048b94159f remove the pstoremanager (will be moved to the Host) 2021-12-08 18:44:20 +04:00
Marten Seemann
4f3790a500 remove metadata interning 2021-12-02 14:11:27 +04:00
Marten Seemann
51974ae06e when passed an event bus, automatically clean up disconnected peers 2021-12-02 12:07:58 +04:00
Marten Seemann
a3a997d014 implement RemovePeer 2021-12-02 11:57:28 +04:00
Marten Seemann
6cf7c68e88 use a separate map to store peer metadata 2021-11-28 11:32:45 +04:00
Marten Seemann
83f5e556c3 remove unnecessary map lookup memeoryPeerMetadata.Put 2021-11-28 11:32:45 +04:00
Marten Seemann
a66346d0c1
chore: update go-log to v2 (#179) 2021-11-27 17:40:23 +04:00
Marten Seemann
5eae6d6caf limit the number of protocols we store per peer 2021-10-22 18:01:08 +02:00
Marten Seemann
3f028c937b reduce mutex contention in SetProtocols 2021-10-22 15:51:34 +02:00
Aarsh Shah
739d9b7c52 remove removal that is not required 2021-07-16 20:03:28 -07:00
Steven Allen
4808543c09 fix: address lints 2021-07-16 10:38:05 -07:00
Steven Allen
cce0adbd0a fix: delete addrs when "updating" them to zero
1. Fix expiration check to check "not before" instead of after.
Otherwise, something that is expiring "now" won't count as expired. The
datastore-backed peerstore already had the correct logic.
2. Short-circuit updating the TTL to 0 and just delete the records.

Note: this wasn't causing problems on Linux (likely due to monotonic
clocks?) but was causing go-libp2p tests to fail reliably on Windows.
2021-04-29 17:20:27 -07:00
Steven Allen
095da5537d fix: make processing signed address records atomic
Previously, two calls to ConsumePeerRecord could interleave and cause us to keep
_old_ addresses with a _new_ record.
2020-06-05 18:36:59 -07:00
Steven Allen
56ebb42d5f fix: always update address TTLs in a signed peer record
Previously, we'd only set the TTL if the addresses were new.
2020-06-05 18:36:56 -07:00
Aarsh Shah
dd0775df6d changes for the new interface 2020-05-11 13:07:08 +05:30
Aarsh Shah
7a58f873f4 peer supports any protocol 2020-05-08 12:10:14 +05:30
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