relay.go 542 Bytes
Newer Older
vyzo's avatar
vyzo committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package relay

import (
	"context"

	discovery "github.com/libp2p/go-libp2p-discovery"
	host "github.com/libp2p/go-libp2p-host"
)

// RelayHost is a Host that provides Relay services.
type RelayHost struct {
	host.Host
	advertise discovery.Advertiser
}

// New constructs a new RelayHost
func NewRelayHost(ctx context.Context, host host.Host, advertise discovery.Advertiser) *RelayHost {
	h := &RelayHost{Host: host, advertise: advertise}
	discovery.Advertise(ctx, advertise, "/libp2p/relay")
	return h
}

var _ host.Host = (*RelayHost)(nil)