go-libp2p-resource-manager/rcmgr.go

60 lines
2.4 KiB
Go
Raw Normal View History

2022-08-18 20:21:11 +08:00
// Deprecated: This package has moved into go-libp2p as a sub-package: github.com/libp2p/go-libp2p/p2p/host/resource-manager.
2021-12-23 21:28:14 +08:00
package rcmgr
import (
2022-08-18 20:21:11 +08:00
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
2021-12-23 21:28:14 +08:00
)
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.Option instead
type Option = rcmgr.Option
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.NewResourceManager instead
func NewResourceManager(limits Limiter, opts ...Option) (network.ResourceManager, error) {
2022-08-18 20:21:11 +08:00
return rcmgr.NewResourceManager(limits, opts...)
2022-06-28 06:42:00 +08:00
}
// GetAllowlist tries to get the allowlist from the given resourcemanager
// interface by checking to see if its concrete type is a resourceManager.
// Returns nil if it fails to get the allowlist.
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.GetAllowlist instead
func GetAllowlist(mgr network.ResourceManager) *Allowlist {
return rcmgr.GetAllowlist(mgr)
2021-12-23 21:28:14 +08:00
}
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.IsSystemScope instead
2022-06-21 07:52:56 +08:00
func IsSystemScope(name string) bool {
2022-08-18 20:21:11 +08:00
return rcmgr.IsSystemScope(name)
2022-06-21 07:52:56 +08:00
}
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.IsTransientScope instead
2022-06-21 07:52:56 +08:00
func IsTransientScope(name string) bool {
2022-08-18 20:21:11 +08:00
return rcmgr.IsTransientScope(name)
2022-06-21 07:52:56 +08:00
}
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.IsConnScope instead
2022-06-21 07:52:56 +08:00
func IsConnScope(name string) bool {
2022-08-18 20:21:11 +08:00
return rcmgr.IsConnScope(name)
2022-06-21 07:52:56 +08:00
}
// ParsePeerScopeName returns "" if name is not a peerScopeName
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.ParsePeerScopeName instead
2022-06-21 07:52:56 +08:00
func ParsePeerScopeName(name string) peer.ID {
2022-08-18 20:21:11 +08:00
return rcmgr.ParsePeerScopeName(name)
2022-06-21 07:52:56 +08:00
}
// ParseServiceScopeName returns the service name if name is a serviceScopeName.
// Otherwise returns ""
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.ParseServiceScopeName instead
2022-06-21 07:52:56 +08:00
func ParseServiceScopeName(name string) string {
2022-08-18 20:21:11 +08:00
return rcmgr.ParseServiceScopeName(name)
2022-06-21 07:52:56 +08:00
}
// ParseProtocolScopeName returns the service name if name is a serviceScopeName.
// Otherwise returns ""
2022-08-18 20:21:11 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/resource-manager.ParseProtocolScopeName instead
2022-06-21 07:52:56 +08:00
func ParseProtocolScopeName(name string) string {
2022-08-18 20:21:11 +08:00
return rcmgr.ParseProtocolScopeName(name)
2021-12-23 21:28:14 +08:00
}