Commit Graph

68 Commits

Author SHA1 Message Date
Steven Allen
517a48433f chore: cleanup addr book patch
1. Remove duplicate import.
2. Lift empty check to simplify code.
3. Use a more efficient map key (go will optimize this to not allocate).
2021-07-20 17:30:09 -07:00
Maxim Merzhanov
8c02e08cd3 reduce complexity in update addr book method 2021-07-20 17:30:09 -07:00
Steven Allen
2c64af26c3 fix: log sequence ds error 2021-07-16 15:40:47 -07:00
Steven Allen
35bbffb1c5 fix: fix some race conditions in the ds address book 2021-07-16 15:37:49 -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
Ignacio Hagopian
1542834878
fix other race
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-06-05 15:17:36 -03:00
Ignacio Hagopian
33ea692817
fix race
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-06-05 15:02:43 -03:00
Steven Allen
785ee8c8fd fix: handle nil peer IDs
Feels like Java all over again.

fixes #87
2020-04-05 23:05:41 -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
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
Raúl Kripalani
662be3b0a4 fix error handling: return on err. 2019-04-16 22:11:14 +01:00
Raúl Kripalani
2c5bc31271 migrate to multiformats/go-base32. 2019-02-28 18:34:51 +00:00
Raúl Kripalani
4806c742b5 pstoreds: remove dirty flag when deleting from db. 2019-02-21 19:31:19 +00:00
Raúl Kripalani
135471f291 add io.Closer interface and implementation to Peerstore. 2019-02-19 11:45:32 +00:00
Raúl Kripalani
4e7d772db3 pstoreds: remove async flushing on read: now sync. 2019-02-18 16:35:48 +00:00
Raúl Kripalani
25f53120b8 gc: drain async flush queue with grace period before closing. 2019-02-15 18:44:05 +00:00
Raúl Kripalani
d7e9f78273 increment WaitGroups before spawning goroutines. 2019-02-15 18:43:34 +00:00
Raúl Kripalani
e16cac9f5e make addrsRecord.Clean() private. 2019-02-06 14:40:51 +00:00
Raúl Kripalani
3966498df4 improve docs; cyclic batch arg; validations. 2019-02-06 14:36:51 +00:00
Raúl Kripalani
fec786e9ef pstore ds: make gc lookahead window optional. 2019-02-06 09:35:10 +00:00
Raúl Kripalani
9da98d7fcf factor out cyclic batch into file; and gc into type. 2019-02-05 17:53:50 +00:00
Raúl Kripalani
20a0dc649d adopt new ds.Write interface. 2019-02-05 16:53:23 +00:00
Raúl Kripalani
d88042c422 improve code readability. 2019-02-05 16:52:27 +00:00
Raúl Kripalani
53d45e9406 make gc operations run on cyclic batches. 2018-12-03 17:40:01 +00:00
Raúl Kripalani
e43a2fc519 drop the need for a transactional datastore; introduce buffer pool. 2018-12-03 15:43:37 +00:00
Raúl Kripalani
8fa350be35 fix raciness in init logic; dedicated goroutines for GC and flushing. 2018-11-30 17:32:51 +00:00
Raúl Kripalani
19eea773fa rename addrsRecord.Refresh() => addrsRecord.Clean(). 2018-11-30 16:56:37 +00:00
Raúl Kripalani
943429ff4b Revert "use a Pool for address record objects." 2018-11-30 16:19:57 +00:00
Raúl Kripalani
c3c24b227a rename GCPruneInterval to GCPurgeInterval for consistency. 2018-11-28 01:29:09 +00:00
Raúl Kripalani
03a40a855a minor cleanup. 2018-11-28 00:56:51 +00:00
Raúl Kripalani
35444fbc6a implement two-tiered lookahead-based GC procedure.
The GC procedure consists of two tiers: lookahead and purge. The
lookahead tier runs less frequently (default 12 hours) than the purge
tier (default 5 minutes).

A lookahead round traverses the entire store and picks entries that
need to be visited in the current lookahead window, pinning those
entries in a separate region in the KV store, indexed by the next visit
timestamp.

A purge round iterates over the lookahead window only, and refreshes
the entries that require a visit. It removes them from the lookahead
region unless the entry requires another visit within the current
window.
2018-11-28 00:13:02 +00:00
Raúl Kripalani
ef8e8ff359 use a Pool for address record objects. 2018-11-15 18:48:40 +00:00
Raúl Kripalani
4c43736fe9 pstoreds: tighten up gc-based peerstore.
Introduces custom types in protobuf to serde directly into multiaddrs
and peer IDs. Simplify purge by ordering addrs by expiry. In general,
getting this readier for merge.
2018-11-15 13:32:08 +00:00
Raúl Kripalani
c423e9e997 pstoreds: migrate from strict TTL to GC-based expiry.
Each entry in the address book KV store now represents a full peer
with all its addresses. Expiries and TTLs are kept inline. Records are
serialised with Protobuf.

Housekeeping is performed on retrieve, and via a periodic GC routine.
The architecture mimics a write-through cache, although not strictly.
2018-11-13 16:57:51 +00:00
Raúl Kripalani
4e2e2de65f ds key encoding: b58 => b32 (no padding). 2018-10-04 10:51:57 +01:00
Raúl Kripalani
1b72b920ed datastore-backed impls of KeyBook and PeerMetadata. 2018-09-28 14:04:52 +01:00
Raúl Kripalani
196ad55260 ds.NewTransaction() can now return an error. 2018-09-27 20:59:57 +01:00
Raúl Kripalani
0f81bdf419 introduce struct for persisted value. 2018-09-18 19:01:24 +01:00
Raúl Kripalani
5b9ad98cc2 remove noop Stop() in address book. 2018-09-18 19:00:07 +01:00
Raúl Kripalani
4b2c1212e7 add a test and fix broken logic. 2018-09-14 18:27:23 +01:00
Raúl Kripalani
3a4d8096cf remove unnecessary return values. 2018-09-14 17:35:49 +01:00
Raúl Kripalani
b75ed37f2b reintroduce import prefixes. 2018-09-13 16:10:14 +01:00
Raúl Kripalani
23be462e82 Merge branch 'txndatastore' into ttldatastore 2018-09-13 16:02:09 +01:00
Raúl Kripalani
7e645fa115 do not prettify cache keys (peer ids). 2018-09-13 15:33:30 +01:00
Raúl Kripalani
afc9ee92b0 performance optimisation round. 2018-09-13 15:33:30 +01:00
Raúl Kripalani
9277207b35 remove deprecated ttlManager. 2018-09-13 12:49:03 +01:00
Raúl Kripalani
80fc9f03ca migrate from bespoke TTL manager to db-managed TTLs. 2018-09-13 12:21:30 +01:00
Raúl Kripalani
c7d99489fd address review comments. 2018-09-12 13:53:10 +01:00