Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
deprecate this repo
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 19, 2022
1 parent 88991ac commit d81fdfd
Show file tree
Hide file tree
Showing 35 changed files with 875 additions and 6,232 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# DEPRECATION NOTICE

This package has moved into go-libp2p as a sub-package, `github.com/libp2p/go-libp2p/p2p/host/peerstore`.


# go-libp2p-peerstore
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](https://libp2p.io/)
Expand Down
5 changes: 0 additions & 5 deletions codecov.yml

This file was deleted.

70 changes: 27 additions & 43 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,40 @@ go 1.17
retract v0.2.9 // Contains backwards-incompatible changes. Use v0.3.0 instead.

require (
github.com/benbjohnson/clock v1.3.0
github.com/gogo/protobuf v1.3.2
github.com/hashicorp/golang-lru v0.5.4
github.com/ipfs/go-datastore v0.5.0
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.3.0
github.com/libp2p/go-buffer-pool v0.0.2
github.com/libp2p/go-libp2p-core v0.12.0
github.com/multiformats/go-base32 v0.0.3
github.com/multiformats/go-multiaddr v0.3.3
github.com/multiformats/go-multiaddr-fmt v0.1.0
github.com/stretchr/testify v1.7.0
go.uber.org/goleak v1.1.10
github.com/ipfs/go-datastore v0.5.1
github.com/libp2p/go-libp2p v0.22.0
)

require (
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgraph-io/badger v1.6.2 // indirect
github.com/dgraph-io/ristretto v0.0.2 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/golang/protobuf v1.3.1 // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/ipfs/go-cid v0.0.7 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/ipfs/go-cid v0.2.0 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/libp2p/go-openssl v0.0.7 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v0.1.1 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-openssl v0.1.0 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-pointer v0.0.1 // indirect
github.com/minio/sha256-simd v1.0.0 // 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.0.3 // indirect
github.com/multiformats/go-multihash v0.0.14 // indirect
github.com/multiformats/go-multiaddr v0.6.0 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.1.1 // indirect
github.com/multiformats/go-multicodec v0.5.0 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // 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.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/tools v0.1.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.22.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
lukechampine.com/blake3 v1.1.7 // indirect
)
793 changes: 739 additions & 54 deletions go.sum

Large diffs are not rendered by default.

55 changes: 11 additions & 44 deletions metrics.go
Original file line number Diff line number Diff line change
@@ -1,58 +1,25 @@
package peerstore

import (
"sync"
"time"

"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/host/peerstore"
)

// 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
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore.LatencyEWMASmoothing instead
var LatencyEWMASmoothing = peerstore.LatencyEWMASmoothing

type metrics struct {
mutex sync.RWMutex
latmap map[peer.ID]time.Duration
type metrics interface {
RecordLatency(peer.ID, time.Duration)
LatencyEWMA(peer.ID) time.Duration
RemovePeer(p peer.ID)
}

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()
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore.NewMetrics instead
func NewMetrics() metrics {
return peerstore.NewMetrics()
}
63 changes: 0 additions & 63 deletions metrics_test.go

This file was deleted.

12 changes: 0 additions & 12 deletions pb/Makefile

This file was deleted.

110 changes: 0 additions & 110 deletions pb/custom.go

This file was deleted.

Loading

0 comments on commit d81fdfd

Please sign in to comment.