proto

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProtoIDv2Hop 是中继协议 v2 版本的 hop 协议标识符
	// 用于在中继节点之间建立连接
	ProtoIDv2Hop = "/dep2p/circuit/relay/0.2.0/hop"

	// ProtoIDv2Stop 是中继协议 v2 版本的 stop 协议标识符
	// 用于终止中继连接
	ProtoIDv2Stop = "/dep2p/circuit/relay/0.2.0/stop"
)

中继协议的版本和类型常量

View Source
const RecordDomain = "dep2p-relay-rsvp"

中继预约服务的记录域名

Variables

View Source
var RecordCodec = []byte{0x03, 0x02}

TODO: 在 https://github.com/multiformats/multicodec 的 multicodec 表中注册

Functions

This section is empty.

Types

type ReservationVoucher

type ReservationVoucher struct {
	// Relay 提供中继服务的节点ID
	Relay peer.ID
	// Peer 通过Relay接收中继服务的节点ID
	Peer peer.ID
	// Expiration 预约的过期时间
	Expiration time.Time
}

ReservationVoucher 表示中继预约的凭证

func (*ReservationVoucher) Codec

func (rv *ReservationVoucher) Codec() []byte

Codec 返回记录的编解码器 返回值:

  • []byte 编解码器字节数组

func (*ReservationVoucher) Domain

func (rv *ReservationVoucher) Domain() string

Domain 返回记录的域名 返回值:

  • string 记录域名

func (*ReservationVoucher) MarshalRecord

func (rv *ReservationVoucher) MarshalRecord() ([]byte, error)

MarshalRecord 将预约凭证序列化为字节数组 返回值:

  • []byte 序列化后的字节数组
  • error 序列化过程中的错误,如果成功则为nil

func (*ReservationVoucher) UnmarshalRecord

func (rv *ReservationVoucher) UnmarshalRecord(blob []byte) error

UnmarshalRecord 从字节数组反序列化预约凭证 参数:

  • blob: []byte 待反序列化的字节数组

返回值:

  • error 反序列化过程中的错误,如果成功则为nil

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL