Skip to content

Commit

Permalink
Merge pull request #1677 from libp2p/merge-rcmgr
Browse files Browse the repository at this point in the history
move go-libp2p-resource-manager to p2p/host/resource-manager
  • Loading branch information
marten-seemann committed Aug 17, 2022
2 parents efbbaa3 + 6bd5e04 commit 6b445e5
Show file tree
Hide file tree
Showing 31 changed files with 9,311 additions and 17 deletions.
2 changes: 1 addition & 1 deletion defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"crypto/rand"

"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
"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 @@ -16,7 +17,6 @@ import (

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

rcmgr "github.com/libp2p/go-libp2p-resource-manager"
"github.com/multiformats/go-multiaddr"
)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
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-resource-manager v0.5.1
github.com/libp2p/go-libp2p-testing v0.11.0
github.com/libp2p/go-mplex v0.7.0
github.com/libp2p/go-msgio v0.2.0
Expand All @@ -42,9 +41,11 @@ require (
github.com/multiformats/go-multihash v0.2.0
github.com/multiformats/go-multistream v0.3.3
github.com/multiformats/go-varint v0.0.6
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
github.com/prometheus/client_golang v1.12.1
github.com/raulk/go-watchdog v1.3.0
github.com/stretchr/testify v1.8.0
go.opencensus.io v0.23.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
Expand Down Expand Up @@ -98,7 +99,6 @@ require (
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
Expand Down Expand Up @@ -351,8 +352,6 @@ github.com/libp2p/go-libp2p-core v0.5.7/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX
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-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=
Expand Down Expand Up @@ -611,6 +610,7 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
Expand Down
3 changes: 1 addition & 2 deletions limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"github.com/libp2p/go-libp2p-core/protocol"

"github.com/libp2p/go-libp2p/p2p/host/autonat"
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
relayv1 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv1/relay"
circuit "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/proto"
relayv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
"github.com/libp2p/go-libp2p/p2p/protocol/holepunch"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
"github.com/libp2p/go-libp2p/p2p/protocol/ping"

rcmgr "github.com/libp2p/go-libp2p-resource-manager"
)

// SetDefaultServiceLimits sets the default limits for bundled libp2p services
Expand Down
16 changes: 8 additions & 8 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ func EnableRelayService(opts ...relayv2.Option) Option {
// EnableAutoRelay configures libp2p to enable the AutoRelay subsystem.
//
// Dependencies:
// * Relay (enabled by default)
// * Routing (to find relays), or StaticRelays/DefaultStaticRelays.
// - Relay (enabled by default)
// - Routing (to find relays), or StaticRelays/DefaultStaticRelays.
//
// This subsystem performs automatic address rewriting to advertise relay addresses when it
// detects that the node is publicly unreachable (e.g. behind a NAT).
Expand Down Expand Up @@ -342,7 +342,7 @@ func ConnectionGater(cg connmgr.ConnectionGater) Option {
}

// ResourceManager configures libp2p to use the given ResourceManager.
// When using the go-libp2p-resource-manager implementation of the ResourceManager interface,
// When using the p2p/host/resource-manager implementation of the ResourceManager interface,
// it is recommended to set limits for libp2p protocol by calling SetDefaultServiceLimits.
func ResourceManager(rcmgr network.ResourceManager) Option {
return func(cfg *Config) error {
Expand Down Expand Up @@ -436,14 +436,14 @@ func MultiaddrResolver(rslv *madns.Resolver) Option {
// to create direct/NAT-traversed connections with other peers. (default: disabled)
//
// Dependencies:
// * Relay (enabled by default)
// - Relay (enabled by default)
//
// This subsystem performs two functions:
//
// 1. On receiving an inbound Relay connection, it attempts to create a direct connection with the remote peer
// by initiating and co-ordinating a hole punch over the Relayed connection.
// 2. If a peer sees a request to co-ordinate a hole punch on an outbound Relay connection,
// it will participate in the hole-punch to create a direct connection with the remote peer.
// 1. On receiving an inbound Relay connection, it attempts to create a direct connection with the remote peer
// by initiating and co-ordinating a hole punch over the Relayed connection.
// 2. If a peer sees a request to co-ordinate a hole punch on an outbound Relay connection,
// it will participate in the hole-punch to create a direct connection with the remote peer.
//
// If the hole punch is successful, all new streams will thereafter be created on the hole-punched connection.
// The Relayed connection will eventually be closed after a grace period.
Expand Down
1 change: 1 addition & 0 deletions p2p/host/peerstore/pstoremem/inmem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ func TestMain(m *testing.M) {
goleak.VerifyTestMain(
m,
goleak.IgnoreTopFunction("github.com/ipfs/go-log/v2/writer.(*MirrorWriter).logRoutine"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
)
}
Loading

0 comments on commit 6b445e5

Please sign in to comment.