mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-25 20:37:27 +08:00
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete * 2.1.0 main node rollup
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package identify
|
|
|
|
import "time"
|
|
|
|
type config struct {
|
|
protocolVersion string
|
|
userAgent string
|
|
disableSignedPeerRecord bool
|
|
metricsTracer MetricsTracer
|
|
timeout time.Duration
|
|
}
|
|
|
|
// Option is an option function for identify.
|
|
type Option func(*config)
|
|
|
|
// ProtocolVersion sets the protocol version string that will be used to
|
|
// identify the family of protocols used by the peer.
|
|
func ProtocolVersion(s string) Option {
|
|
return func(cfg *config) {
|
|
cfg.protocolVersion = s
|
|
}
|
|
}
|
|
|
|
// UserAgent sets the user agent this node will identify itself with to peers.
|
|
func UserAgent(ua string) Option {
|
|
return func(cfg *config) {
|
|
cfg.userAgent = ua
|
|
}
|
|
}
|
|
|
|
// DisableSignedPeerRecord disables populating signed peer records on the outgoing Identify response
|
|
// and ONLY sends the unsigned addresses.
|
|
func DisableSignedPeerRecord() Option {
|
|
return func(cfg *config) {
|
|
cfg.disableSignedPeerRecord = true
|
|
}
|
|
}
|
|
|
|
func WithMetricsTracer(tr MetricsTracer) Option {
|
|
return func(cfg *config) {
|
|
cfg.metricsTracer = tr
|
|
}
|
|
}
|
|
|
|
// WithTimeout sets the timeout for identify interactions.
|
|
func WithTimeout(timeout time.Duration) Option {
|
|
return func(cfg *config) {
|
|
cfg.timeout = timeout
|
|
}
|
|
}
|