Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move go-libp2p-peerstore to p2p/host/peerstore #1667

Merged
merged 384 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
384 commits
Select commit Hold shift + click to select a range
d20a98c
rename package mem => pstoremem.
raulk Sep 4, 2018
7f38aaf
rename AddrMgr => AddrBook elsewhere.
raulk Sep 5, 2018
6959b23
rename NewPeerstoreWith(...) => NewPeerstore(...); adjust godoc.
raulk Sep 5, 2018
2818d65
increase wait times in tests.
raulk Sep 6, 2018
65adc76
add mafmt import alias.
raulk Sep 7, 2018
ad9ccb9
Merge pull request #30 from raulk/refactor
raulk Sep 7, 2018
888f631
add tests for keybook; []peer.ID => peer.IDSlice.
raulk Aug 31, 2018
9229870
optimise benchmark code.
raulk Aug 31, 2018
cd0cdec
nested test cases in addr_book suite.
raulk Sep 7, 2018
8abb8a3
migrate Addrs() and PeersWithAddrs() to use txns, improve perf, bench…
raulk Sep 7, 2018
9a52623
regroup test utils; remove unused function.
raulk Sep 7, 2018
55afe7b
normalise import aliases.
raulk Sep 7, 2018
1e12471
Merge pull request #32 from raulk/keybook-tests
raulk Sep 7, 2018
ea75b18
add baseline benchmarks.
raulk Sep 10, 2018
5c6b53e
change cache layout, now peer.ID => []ma.Multiaddr.
raulk Sep 11, 2018
de70a75
check cache in ClearAddrs and perform targeted delete.
raulk Sep 11, 2018
32aa55e
Merge branch 'master' into txndatastore
raulk Sep 11, 2018
6b61869
fix bug in PeersWithAddrs().
raulk Sep 11, 2018
22da141
small fixes.
raulk Sep 11, 2018
78f457d
increase test coverage.
raulk Sep 11, 2018
71e08d9
Resolve TODO.
raulk Sep 12, 2018
202fdc2
address review comments.
raulk Sep 12, 2018
4433afc
hopefully fix intermittent time-dependent test failure.
raulk Sep 12, 2018
b9b3939
attempt to fix time-dependent tests in CI.
raulk Sep 13, 2018
80894be
migrate from bespoke TTL manager to db-managed TTLs.
raulk Sep 12, 2018
db643f3
remove deprecated ttlManager.
raulk Sep 13, 2018
e38ee5c
performance optimisation round.
raulk Sep 13, 2018
18e0eeb
do not prettify cache keys (peer ids).
raulk Sep 13, 2018
7ebb753
Merge branch 'txndatastore' into ttldatastore
raulk Sep 13, 2018
57ae658
adjust ttl tests as badger doesn't support sub-second ttl.
raulk Sep 13, 2018
ad173ae
reintroduce import prefixes.
raulk Sep 13, 2018
1d8bbeb
Merge pull request #33 from raulk/txndatastore
raulk Sep 14, 2018
e77452b
remove unnecessary return values.
raulk Sep 14, 2018
a6fcd7f
add a test and fix broken logic.
raulk Sep 14, 2018
b6e2680
remove noop Stop() in address book.
raulk Sep 18, 2018
35a1fb3
introduce struct for persisted value.
raulk Sep 18, 2018
0bff9f8
Merge pull request #34 from libp2p/ttldatastore
raulk Sep 20, 2018
22c953c
ds.NewTransaction() can now return an error.
raulk Sep 27, 2018
43ad732
Merge pull request #36 from libp2p/txn-err
raulk Sep 27, 2018
9961608
datastore-backed impls of KeyBook and PeerMetadata.
raulk Sep 28, 2018
0531abf
add explicit import aliases.
raulk Sep 28, 2018
78cfb8b
review comments.
raulk Sep 28, 2018
0b3d0ee
Merge pull request #37 from raulk/ds-backed-keybook-metadata
raulk Sep 29, 2018
382eb83
revert to storing peer addresses in a map
Stebalien Oct 2, 2018
a0a98a9
add garbage collection for in-memory peerstore
Stebalien Oct 2, 2018
7084551
memoryAddrBook: document gc precondition
Stebalien Oct 4, 2018
adb7b2c
Merge pull request #39 from libp2p/fix/allocations
Stebalien Oct 4, 2018
0cc0faf
run tests against multiple datastores.
raulk Oct 4, 2018
c95b4a8
ds key encoding: b58 => b32 (no padding).
raulk Oct 4, 2018
7cb7023
Merge pull request #40 from raulk/b32
raulk Oct 11, 2018
c2190b4
store expiring addrs by pointer
Stebalien Oct 14, 2018
0b11d14
Merge pull request #41 from libp2p/fix/smaller-addr-book
raulk Oct 16, 2018
8ddcc58
update to match new ExtractPublicKey API
Stebalien Oct 16, 2018
7a020ce
Merge pull request #42 from libp2p/feat/fix-peer-inlining
Stebalien Oct 16, 2018
5f4a118
fix the inline key test
Stebalien Nov 2, 2018
64945af
Merge pull request #44 from libp2p/fix/inline-test
Stebalien Nov 2, 2018
8fb174c
prevent timeout by un-nesting tb.Runs
lanzafame Oct 29, 2018
9c6157d
sort suite so benchmarks always run in the same order
lanzafame Oct 29, 2018
56ce954
add keybook benchmarks
lanzafame Oct 29, 2018
5d053a2
PeerInfo UnMarshal Error #393
Nov 8, 2018
fc976fd
bug fix: UnmarshalJSON should take a pointer
zhizouxiao Nov 8, 2018
e4c99a1
add marshal unittest #393
Nov 9, 2018
0596636
Merge pull request #45 from zhizouxiao/fix/peerinfo-unmarshal
Stebalien Nov 9, 2018
e587133
pstoreds: migrate from strict TTL to GC-based expiry.
raulk Nov 12, 2018
835ae99
Merge pull request #43 from lanzafame/feat/more-benchs
raulk Nov 14, 2018
01bb521
pstoreds: tighten up gc-based peerstore.
raulk Nov 15, 2018
909782c
fix makefile for protobuf.
raulk Nov 15, 2018
9325339
Merge branch 'master' into feat/pstore-ds-gc
raulk Nov 15, 2018
664ef32
adjust GC interval in tests.
raulk Nov 15, 2018
a6534f5
add Keys() function to private cache interface for completeness.
raulk Nov 15, 2018
10c51a8
use a Pool for address record objects.
raulk Nov 15, 2018
a52733e
implement two-tiered lookahead-based GC procedure.
raulk Nov 26, 2018
a90dec5
add tests for new GC routines.
raulk Nov 28, 2018
2211993
minor cleanup.
raulk Nov 28, 2018
4fc69bd
improve test coverage of new GC routine.
raulk Nov 28, 2018
7ffff3d
rename GCPruneInterval to GCPurgeInterval for consistency.
raulk Nov 28, 2018
05b8d7f
document custom gogo types; reorg code.
raulk Nov 30, 2018
97374b3
Revert "use a Pool for address record objects."
raulk Nov 30, 2018
ecfe476
rename addrsRecord.Refresh() => addrsRecord.Clean().
raulk Nov 30, 2018
c822dae
fix raciness in init logic; dedicated goroutines for GC and flushing.
raulk Nov 30, 2018
6dda428
drop the need for a transactional datastore; introduce buffer pool.
raulk Dec 3, 2018
58828e8
add a benchmark for lookahead cycles.
raulk Dec 3, 2018
9f17c40
make gc operations run on cyclic batches.
raulk Dec 3, 2018
aa4a32b
return error when committing a closed cyclic batch.
raulk Dec 4, 2018
98a47e9
disable inline-peer id test
Stebalien Dec 7, 2018
bdd0cd6
Merge pull request #49 from libp2p/fix/disable-inline-pid-test
Stebalien Dec 7, 2018
0e9ce4e
add unit test to verify AddAddr doesn't shorten TTL.
raulk Jan 23, 2019
e7c54d6
pstore ds: enforce order in gc queries.
raulk Feb 5, 2019
d3ce7dc
Merge pull request #52 from raulk/master
raulk Feb 5, 2019
1027dcb
Merge branch 'master' into feat/pstore-ds-gc
raulk Feb 5, 2019
042ae93
improve code readability.
raulk Feb 5, 2019
629d11f
adopt new ds.Write interface.
raulk Feb 5, 2019
888582c
factor out cyclic batch into file; and gc into type.
raulk Feb 5, 2019
c0eb65b
pstore ds: make gc lookahead window optional.
raulk Feb 6, 2019
7bd040c
improve docs; cyclic batch arg; validations.
raulk Feb 6, 2019
fa5c778
make addrsRecord.Clean() private.
raulk Feb 6, 2019
1297596
change default purge interval to 2 hours.
raulk Feb 6, 2019
b5b6b71
fix tests; run lookahead after initial delay.
raulk Feb 6, 2019
2327766
increment WaitGroups before spawning goroutines.
raulk Feb 15, 2019
8be0831
gc: drain async flush queue with grace period before closing.
raulk Feb 15, 2019
af0c6bd
pstoreds: remove async flushing on read: now sync.
raulk Feb 18, 2019
6b6b7a3
add io.Closer interface and implementation to Peerstore.
raulk Feb 19, 2019
9a5e27a
pstoreds: switch protobuf compilation to gogofaster.
raulk Feb 19, 2019
3a30a4e
pstoreds: remove dirty flag when deleting from db.
raulk Feb 21, 2019
6a955ca
pstore.Close(): return errors from children.
raulk Feb 22, 2019
0c66884
Merge pull request #47 from raulk/feat/pstore-ds-gc
raulk Feb 22, 2019
2dd6b7c
migrate to multiformats/go-base32.
raulk Feb 28, 2019
4943e51
Implement fmt.Stringer for PeerInfo
anacrolix Mar 8, 2019
25d32c5
Add to comment on KeyBook.PrivKey (#64)
anacrolix Apr 8, 2019
018d54f
keep temp addresses for 2 minutes
Stebalien Apr 12, 2019
50176ec
Merge pull request #67 from libp2p/fix/keep-temp-addresses
Stebalien Apr 12, 2019
6d47278
fix error handling: return on err.
raulk Apr 16, 2019
c14eeb5
Merge pull request #70 from libp2p/fix/err-handling
raulk Apr 16, 2019
60c8703
optimize memory of in-memory peerstore
Stebalien Apr 23, 2019
7b78257
intern protocol names
Stebalien Apr 23, 2019
3a98ccd
fix unmarshalling of peer IDs
Stebalien Apr 23, 2019
e70a6ed
Merge pull request #72 from libp2p/fix/unmarshal-peer-id
Stebalien Apr 23, 2019
30857c1
peerstore: bump number/size of interned protocol names
Stebalien Apr 23, 2019
67d636f
Merge pull request #71 from libp2p/feat/optimize-mem
Stebalien Apr 23, 2019
e502282
read/write protocol lock
vyzo Apr 27, 2019
bacd7c9
read/write address book lock
vyzo Apr 27, 2019
db8f683
read/write metadata lock
vyzo Apr 27, 2019
fa5d96f
Merge pull request #74 from libp2p/feat/rwlock
Stebalien Apr 27, 2019
fd9ff6b
don't delete under the read lock
vyzo Apr 28, 2019
21e6513
periodically schedule gc
vyzo Apr 28, 2019
4bdabc4
add Close method to memory address book, which cancels the gc process
vyzo Apr 28, 2019
3dd2b42
don't eager gc
vyzo Apr 28, 2019
5d110a4
Merge pull request #76 from libp2p/fix/issue-75
Stebalien Apr 28, 2019
4f9f731
segment the memory peerstore; granular locks.
raulk May 8, 2019
eff34c5
update segment size on gc
vyzo May 9, 2019
0c0b648
segmented protocol info
vyzo May 9, 2019
157f460
refactor protocol functionality into ProtoBook
vyzo May 17, 2019
bac2734
embed lock in segment
vyzo May 17, 2019
e30651c
global interned protocol table
vyzo May 17, 2019
12eafa0
implement protobook for pstoreds
vyzo May 17, 2019
e531639
cosmetics
vyzo May 17, 2019
ba7cb93
index the peer ID strings directly to avoid copying the byte slice
vyzo May 17, 2019
1a7ee91
don't track segment sizes, it's a fruitless optimization
vyzo May 17, 2019
0ab5967
make lock methods private
vyzo May 17, 2019
f4a4d80
use segments in ds protobook instead of a lock array
vyzo May 18, 2019
ff02b44
Merge pull request #78 from libp2p/feat/segmented-map
vyzo May 18, 2019
075e2a2
Consolidate abstractions and core types into go-libp2p-core (#69)
raulk May 23, 2019
a862d91
feat: improve protocol interning
Stebalien May 27, 2019
5197d8f
feat: intern agent versions
Stebalien May 27, 2019
fd88712
Merge pull request #79 from libp2p/feat/better-intern
Stebalien May 28, 2019
73b10b9
dep: switch to core (#80)
Stebalien May 31, 2019
74ed339
set map in constructor
whyrusleeping Jun 1, 2019
bb7e91a
Merge pull request #81 from libp2p/fix/interned-nil-panic
Stebalien Jun 1, 2019
31ec77d
test: add metadata test
Stebalien Jun 1, 2019
04e5878
Merge pull request #82 from libp2p/test/metadata
Stebalien Jun 1, 2019
d297b44
protobook: support removing protocols. (#84)
raulk Jun 19, 2019
4f10263
reduce allocations when adding addrs
Stebalien Jun 28, 2019
86bfe83
Merge pull request #86 from libp2p/fix/alloc-less
Stebalien Jun 28, 2019
633b771
make RemoveProtocols take the write lock. (#90)
raulk Jul 10, 2019
4d31474
fix multiple TTL bugs
Stebalien Jul 24, 2019
a785eb2
Merge pull request #92 from libp2p/fix/identify-2
Stebalien Jul 25, 2019
62b9a38
chore(dep): update deps
Stebalien Oct 28, 2019
fc51534
Merge pull request #95 from libp2p/chore/update-deps
Stebalien Oct 28, 2019
67313c2
chore(dep): update go-log
Stebalien Feb 17, 2020
637e7e4
Merge pull request #121 from libp2p/chore/update-ds
Stebalien Feb 21, 2020
00b792c
Correct path to peer.AddrInfo in deprecation
jbn Feb 25, 2020
53a6f36
Merge pull request #124 from jbn/master
Stebalien Feb 25, 2020
75bd6d5
Certified addresses (#98)
yusefnapora Mar 6, 2020
6ca3f72
fix: make close work again
Stebalien Mar 23, 2020
24eeef5
test: check for goroutine leaks when closing the peerstore
Stebalien Mar 23, 2020
ba0d995
Merge pull request #131 from libp2p/fix/peerstore-close
Stebalien Mar 23, 2020
394a5e7
fix memory store signed peer record bug
aarshkshah1992 Mar 27, 2020
0134a89
fix add addrs bug
aarshkshah1992 Mar 28, 2020
0d1a8fe
Merge pull request #133 from libp2p/feat/fix-addrs-bug
Stebalien Mar 30, 2020
9d18160
fix: handle nil peer IDs
Stebalien Jul 2, 2019
104663b
Merge pull request #88 from libp2p/fix/87
Stebalien Apr 6, 2020
61d64b6
peer supports any protocol
aarshkshah1992 May 8, 2020
371ef2d
changes for the new interface
aarshkshah1992 May 11, 2020
1d296f2
Merge pull request #147 from libp2p/feat/supports-no-alloc
aarshkshah1992 May 14, 2020
e0c1054
fix race
jsign Jun 5, 2020
46476b0
fix other race
jsign Jun 5, 2020
c1e65cb
Merge pull request #154 from jsign/jsign/fixraces
vyzo Jun 5, 2020
4410dcf
fix: always update address TTLs in a signed peer record
Stebalien Jun 6, 2020
1d1a2ef
fix: make processing signed address records atomic
Stebalien Jun 6, 2020
0a5fa8d
Merge pull request #155 from libp2p/fix/peer-record-bugs
Stebalien Jun 8, 2020
1abc953
fix: delete addrs when "updating" them to zero
Stebalien Apr 29, 2021
4cfafa2
Merge pull request #157 from libp2p/fix/delete-addrs-update-zero
Stebalien Apr 30, 2021
ebd49df
stop using the deprecated go-multiaddr-net package
marten-seemann Jul 2, 2021
178dd6a
Merge pull request #158 from libp2p/remove-go-multiaddr-net
marten-seemann Jul 2, 2021
90ce278
fix: avoid copying locks/waitgroups
Stebalien Jul 16, 2021
028a2a0
chore: update deps
Stebalien Jul 16, 2021
139ba7f
chore: update to latest go error handling
Stebalien Jul 16, 2021
58c928b
fix: address lints
Stebalien Jul 16, 2021
04b0a14
Merge pull request #159 from libp2p/fix/lints
Stebalien Jul 16, 2021
db3b86b
fix: fix some race conditions in the ds address book
Stebalien Jul 16, 2021
6ee1e66
fix: log sequence ds error
Stebalien Jul 16, 2021
827acb2
Merge pull request #161 from libp2p/fix/races
Stebalien Jul 17, 2021
88970d2
test: use leveldb instead of badger
Stebalien Jul 16, 2021
eeff701
test: make tests less timing dependent
Stebalien Jul 16, 2021
27386f6
Merge pull request #160 from libp2p/web3-bot/sync
Stebalien Jul 17, 2021
96defad
remove removal that is not required
aarshkshah1992 Apr 1, 2020
17f3bbb
Merge pull request #135 from libp2p/feat/remove-non-gc-removal
Stebalien Jul 17, 2021
cdd1317
fix: assert that peer record is accepted in test
Stebalien Jul 20, 2021
e02564c
test: don't run datastore tests in parallel
Stebalien Jul 21, 2021
3862aa4
test: make the "add" test less timing dependent
Stebalien Jul 21, 2021
cc47907
fix: avoid using the disk in datastore tests
Stebalien Jul 21, 2021
d2e8b2e
Merge pull request #164 from libp2p/fix/test-flakes
Stebalien Jul 21, 2021
c3ef0ea
reduce complexity in update addr book method
pymq Apr 12, 2020
13ae98f
chore: cleanup addr book patch
Stebalien Jul 20, 2021
c5ef661
Merge pull request #141 from pymq/fix_update_addrbook_loop
Stebalien Jul 21, 2021
3073084
remove deprecated types
marten-seemann Jul 22, 2021
d4a7b48
Merge pull request #165 from libp2p/remove-deprecated-types
Stebalien Jul 22, 2021
2475a45
feat: remove queue
Stebalien Jul 23, 2021
370db7b
Merge pull request #166 from libp2p/fix/remove-queue
Stebalien Jul 23, 2021
79d907b
fix: replace deprecated call
muXxer Aug 12, 2021
6ea1642
Merge pull request #168 from muXxer/fix/replace-deprecated-call
marten-seemann Aug 14, 2021
50dac7c
reduce mutex contention in SetProtocols
marten-seemann Oct 22, 2021
88fc1d3
limit the number of protocols we store per peer
marten-seemann Oct 22, 2021
53e6bac
remove leftover peerstore implementation in the root package
marten-seemann Oct 23, 2021
6a7533e
Merge pull request #173 from libp2p/remove-leftover-peerstore
marten-seemann Oct 23, 2021
b7a856c
feat: plumb through datastore contexts (#176)
guseggert Oct 28, 2021
9449b32
Merge pull request #172 from libp2p/limit-protocols
marten-seemann Oct 29, 2021
3238e0d
chore: update go-log to v2 (#179)
marten-seemann Nov 27, 2021
5fdf4ec
remove unnecessary map lookup memeoryPeerMetadata.Put
marten-seemann Oct 23, 2021
abcee6d
use a separate map to store peer metadata
marten-seemann Oct 23, 2021
c09461e
implement RemovePeer
marten-seemann Oct 23, 2021
786bbd4
Merge pull request #174 from libp2p/remove-peer
marten-seemann Dec 2, 2021
e48bac5
when passed an event bus, automatically clean up disconnected peers
marten-seemann Nov 27, 2021
7be535b
Merge pull request #184 from libp2p/pstore-cleanup
marten-seemann Dec 2, 2021
0364daa
remove metadata interning
marten-seemann Dec 2, 2021
584b33d
Merge pull request #185 from libp2p/remove-interning
marten-seemann Dec 2, 2021
b5c7bda
remove the pstoremanager (will be moved to the Host)
marten-seemann Dec 8, 2021
3e3dd7b
Merge pull request #188 from libp2p/remove-manager
marten-seemann Dec 10, 2021
1fcf17b
avoid unnecessary allocation when gc'ing the addrbook
marten-seemann Dec 14, 2021
29b0ab8
remove unnecessary map allocation when adding addresses
marten-seemann Dec 14, 2021
325d729
optimize map lookup when adding addresses
marten-seemann Dec 14, 2021
58c639a
implement a clean shutdown for the memory address book
marten-seemann Dec 14, 2021
b40a117
Merge pull request #192 from libp2p/clean-shutdown
marten-seemann Dec 14, 2021
2da8c8d
Merge pull request #191 from libp2p/various-addr-book-optimizations
marten-seemann Dec 14, 2021
aedfd63
move AddrList to pstoremen, unexport it
marten-seemann Dec 19, 2021
f9a486a
Merge pull request #193 from libp2p/move-sorting
marten-seemann Dec 19, 2021
ead3cdd
remove all calls to peer.ID.Validate
marten-seemann Dec 19, 2021
0466498
remove the addr package
marten-seemann Dec 19, 2021
7195c20
Merge pull request #195 from libp2p/remove-addr-package
marten-seemann Dec 19, 2021
abc52a3
Merge pull request #194 from libp2p/remove-validate
marten-seemann Jan 3, 2022
8a547c5
pstoremem: fix slice preallocation in GetProtocols (#198)
mrd0ll4r Apr 21, 2022
832b0bd
Use a clock interface to better support testing
MarcoPolo May 25, 2022
1da4a8e
Merge pull request #199 from libp2p/marco/with-clock
MarcoPolo May 26, 2022
c2f25ed
Use mock clock in pstoreds and tests
MarcoPolo May 26, 2022
7108bf5
Merge pull request #200 from libp2p/marco/with-clock-2
MarcoPolo May 27, 2022
29bf33f
stop using the peer.Set (#201)
marten-seemann Jun 27, 2022
9161f4a
fix flaky EWMA test (#205)
marten-seemann Aug 12, 2022
6d53e63
fix flaky TestGCDelay (#206)
marten-seemann Aug 12, 2022
a9e8f79
move go-libp2p-peerstore here
marten-seemann Aug 15, 2022
ab634d2
switch from github.com/libp2p/go-libp2p-peerstore to p2p/host/peerstore
marten-seemann Aug 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"github.com/libp2p/go-libp2p-core/routing"
"github.com/libp2p/go-libp2p-core/sec"
"github.com/libp2p/go-libp2p-core/transport"
"github.com/libp2p/go-libp2p-peerstore/pstoremem"

"github.com/libp2p/go-libp2p/p2p/host/autonat"
"github.com/libp2p/go-libp2p/p2p/host/autorelay"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
blankhost "github.com/libp2p/go-libp2p/p2p/host/blank"
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
routed "github.com/libp2p/go-libp2p/p2p/host/routed"
"github.com/libp2p/go-libp2p/p2p/net/swarm"
tptu "github.com/libp2p/go-libp2p/p2p/net/upgrader"
Expand Down
2 changes: 1 addition & 1 deletion defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package libp2p
import (
"crypto/rand"

"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
"github.com/libp2p/go-libp2p/p2p/net/connmgr"
"github.com/libp2p/go-libp2p/p2p/security/noise"
Expand All @@ -15,7 +16,6 @@ import (

"github.com/libp2p/go-libp2p-core/crypto"

"github.com/libp2p/go-libp2p-peerstore/pstoremem"
rcmgr "github.com/libp2p/go-libp2p-resource-manager"
"github.com/multiformats/go-multiaddr"
)
Expand Down
13 changes: 11 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ require (
github.com/hashicorp/golang-lru v0.5.4
github.com/ipfs/go-cid v0.2.0
github.com/ipfs/go-datastore v0.5.1
github.com/ipfs/go-ds-badger v0.3.0
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/jbenet/go-temp-err-catcher v0.1.0
github.com/klauspost/compress v1.15.1
github.com/libp2p/go-buffer-pool v0.1.0
github.com/libp2p/go-eventbus v0.2.1
github.com/libp2p/go-libp2p-asn-util v0.2.0
github.com/libp2p/go-libp2p-core v0.19.1
github.com/libp2p/go-libp2p-peerstore v0.7.1
github.com/libp2p/go-libp2p-resource-manager v0.5.1
github.com/libp2p/go-libp2p-testing v0.11.0
github.com/libp2p/go-mplex v0.7.0
Expand All @@ -34,6 +35,7 @@ require (
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b
github.com/minio/sha256-simd v1.0.0
github.com/multiformats/go-base32 v0.0.4
github.com/multiformats/go-multiaddr v0.6.0
github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/multiformats/go-multiaddr-fmt v0.1.0
Expand All @@ -43,28 +45,35 @@ require (
github.com/prometheus/client_golang v1.12.1
github.com/raulk/go-watchdog v1.3.0
github.com/stretchr/testify v1.8.0
go.uber.org/goleak v1.1.12
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
)

require (
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgraph-io/badger v1.6.2 // indirect
github.com/dgraph-io/ristretto v0.0.2 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
Expand All @@ -83,7 +92,6 @@ require (
github.com/miekg/dns v1.1.50 // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.0.4 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multibase v0.1.1 // indirect
github.com/multiformats/go-multicodec v0.5.0 // indirect
Expand All @@ -98,6 +106,7 @@ require (
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
Expand Down
22 changes: 11 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr
dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M=
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -121,11 +123,15 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4=
Expand Down Expand Up @@ -201,6 +207,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -269,12 +276,13 @@ github.com/ipfs/go-datastore v0.5.1 h1:WkRhLuISI+XPD0uk3OskB0fYFSyqK8Ob5ZYew9Qa1
github.com/ipfs/go-datastore v0.5.1/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
github.com/ipfs/go-ds-badger v0.3.0 h1:xREL3V0EH9S219kFFueOYJJTcjgNSZ2HY1iSvN7U1Ro=
github.com/ipfs/go-ds-badger v0.3.0/go.mod h1:1ke6mXNqeV8K3y5Ak2bAA0osoTfmxUdupVCGm4QUIek=
github.com/ipfs/go-ds-leveldb v0.5.0 h1:s++MEBbD3ZKc9/8/njrn4flZLnCuY9I79v94gBUNumo=
github.com/ipfs/go-ds-leveldb v0.5.0/go.mod h1:d3XG9RUDzQ6V4SHi8+Xgj9j1XuEk1z82lquxrVbml/Q=
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ=
github.com/ipfs/go-log/v2 v2.0.5/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscwkWG+dw=
github.com/ipfs/go-log/v2 v2.3.0/go.mod h1:QqGoj30OTpnKaG/LKTGTxoP2mmQtjVMEnK72gynbe/g=
github.com/ipfs/go-log/v2 v2.5.0/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY=
github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
Expand Down Expand Up @@ -340,18 +348,14 @@ github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/
github.com/libp2p/go-libp2p-asn-util v0.2.0/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI=
github.com/libp2p/go-libp2p-core v0.2.0/go.mod h1:X0eyB0Gy93v0DZtSYbEM7RnMChm9Uv3j7yRXjO77xSI=
github.com/libp2p/go-libp2p-core v0.5.7/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo=
github.com/libp2p/go-libp2p-core v0.12.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQRAMf0sX9mf2sbGg=
github.com/libp2p/go-libp2p-core v0.19.0/go.mod h1:AkA+FUKQfYt1FLNef5fOPlo/naAWjKy/RCjkcPjqzYg=
github.com/libp2p/go-libp2p-core v0.19.1 h1:zaZQQCeCrFMtxFa1wHy6AhsVynyNmZAvwgWqSSPT3WE=
github.com/libp2p/go-libp2p-core v0.19.1/go.mod h1:2uLhmmqDiFY+dw+70KkBLeKvvsJHGWUINRDdeV1ip7k=
github.com/libp2p/go-libp2p-peerstore v0.7.1 h1:7FpALlqR+3+oOBXdzm3AVt0vjMYLW1b7jM03E4iEHlw=
github.com/libp2p/go-libp2p-peerstore v0.7.1/go.mod h1:cdUWTHro83vpg6unCpGUr8qJoX3e93Vy8o97u5ppIM0=
github.com/libp2p/go-libp2p-resource-manager v0.5.1 h1:jm0mdqn7yfh7wbUzlj948BYZX0KZ3RW7OqerkGQ5rYY=
github.com/libp2p/go-libp2p-resource-manager v0.5.1/go.mod h1:CggtV6EZb+Y0dGh41q5ezO4udcVKyhcEFpydHD8EMe0=
github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.11.0 h1:+R7FRl/U3Y00neyBSM2qgDzqz3HkWH24U9nMlascHL4=
github.com/libp2p/go-libp2p-testing v0.11.0/go.mod h1:qG4sF27dfKFoK9KlVzK2y52LQKhp0VEmLjV5aDqr1Hg=
github.com/libp2p/go-maddr-filter v0.1.0/go.mod h1:VzZhTXkMucEGGEOSKddrwGiOv0tUhgnKqNEmIAz/bPU=
github.com/libp2p/go-mplex v0.7.0 h1:BDhFZdlk5tbr0oyFq/xv/NPGfjbnrsDam1EvutpBDbY=
github.com/libp2p/go-mplex v0.7.0/go.mod h1:rW8ThnRcYWft/Jb2jeORBmPd6xuG3dGxWN/W168L9EU=
github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ=
Expand Down Expand Up @@ -392,7 +396,6 @@ github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
Expand Down Expand Up @@ -438,7 +441,6 @@ github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lg
github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo=
github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4=
github.com/multiformats/go-multiaddr v0.2.2/go.mod h1:NtfXiOtHvghW9KojvtySjH5y0u0xW5UouOmQQrn6a3Y=
github.com/multiformats/go-multiaddr v0.3.3/go.mod h1:lCKNGP1EQ1eZ35Za2wlqnabm9xQkib3fyB+nZXHLag0=
github.com/multiformats/go-multiaddr v0.4.1/go.mod h1:3afI9HfVW8csiF8UZqtpYRiDyew8pRX7qLIGHu9FLuM=
github.com/multiformats/go-multiaddr v0.6.0 h1:qMnoOPj2s8xxPU5kZ57Cqdr0hHhARz7mFsPMIiYNqzg=
github.com/multiformats/go-multiaddr v0.6.0/go.mod h1:F4IpaKZuPP360tOMn2Tpyu0At8w23aRyVqeK0DbFeGM=
Expand Down Expand Up @@ -588,6 +590,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
Expand All @@ -613,7 +616,6 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
Expand All @@ -624,7 +626,6 @@ go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
Expand Down Expand Up @@ -677,6 +678,7 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand Down Expand Up @@ -795,7 +797,6 @@ golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -870,7 +871,6 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
58 changes: 58 additions & 0 deletions p2p/host/peerstore/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package peerstore

import (
"sync"
"time"

"github.com/libp2p/go-libp2p-core/peer"
)

// LatencyEWMASmoothing governs the decay of the EWMA (the speed
// at which it changes). This must be a normalized (0-1) value.
// 1 is 100% change, 0 is no change.
var LatencyEWMASmoothing = 0.1

type metrics struct {
mutex sync.RWMutex
latmap map[peer.ID]time.Duration
}

func NewMetrics() *metrics {
return &metrics{
latmap: make(map[peer.ID]time.Duration),
}
}

// RecordLatency records a new latency measurement
func (m *metrics) RecordLatency(p peer.ID, next time.Duration) {
nextf := float64(next)
s := LatencyEWMASmoothing
if s > 1 || s < 0 {
s = 0.1 // ignore the knob. it's broken. look, it jiggles.
}

m.mutex.Lock()
ewma, found := m.latmap[p]
ewmaf := float64(ewma)
if !found {
m.latmap[p] = next // when no data, just take it as the mean.
} else {
nextf = ((1.0 - s) * ewmaf) + (s * nextf)
m.latmap[p] = time.Duration(nextf)
}
m.mutex.Unlock()
}

// LatencyEWMA returns an exponentially-weighted moving avg.
// of all measurements of a peer's latency.
func (m *metrics) LatencyEWMA(p peer.ID) time.Duration {
m.mutex.RLock()
defer m.mutex.RUnlock()
return m.latmap[p]
}

func (m *metrics) RemovePeer(p peer.ID) {
m.mutex.Lock()
delete(m.latmap, p)
m.mutex.Unlock()
}
63 changes: 63 additions & 0 deletions p2p/host/peerstore/metrics_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package peerstore

import (
"fmt"
"math/rand"
"testing"
"time"

"github.com/libp2p/go-libp2p-core/test"
)

func TestLatencyEWMAFun(t *testing.T) {
t.Skip("run it for fun")

m := NewMetrics()
id, err := test.RandPeerID()
if err != nil {
t.Fatal(err)
}

mu := 100.0
sig := 10.0
next := func() time.Duration {
mu = (rand.NormFloat64() * sig) + mu
return time.Duration(mu)
}

print := func() {
fmt.Printf("%3.f %3.f --> %d\n", sig, mu, m.LatencyEWMA(id))
}

for {
time.Sleep(200 * time.Millisecond)
m.RecordLatency(id, next())
print()
}
}

func TestLatencyEWMA(t *testing.T) {
m := NewMetrics()
id, err := test.RandPeerID()
if err != nil {
t.Fatal(err)
}

const exp = 100
const mu = exp
const sig = 10
next := func() time.Duration { return time.Duration(rand.Intn(20) - 10 + mu) }

for i := 0; i < 10; i++ {
m.RecordLatency(id, next())
}

lat := m.LatencyEWMA(id)
diff := exp - lat
if diff < 0 {
diff = -diff
}
if diff > sig {
t.Fatalf("latency outside of expected range. expected %d ± %d, got %d", exp, sig, lat)
}
}
Loading