Source File
voucher.go
Belonging Package
github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/proto
package protoimport (pbv2)const RecordDomain = "libp2p-relay-rsvp"// TODO: register in multicodec table in https://github.com/multiformats/multicodecvar RecordCodec = []byte{0x03, 0x02}func init() {record.RegisterType(&ReservationVoucher{})}type ReservationVoucher struct {// Relay is the ID of the peer providing relay serviceRelay peer.ID// Peer is the ID of the peer receiving relay service through RelayPeer peer.ID// Expiration is the expiration time of the reservationExpiration time.Time}var _ record.Record = (*ReservationVoucher)(nil)func ( *ReservationVoucher) () string {return RecordDomain}func ( *ReservationVoucher) () []byte {return RecordCodec}func ( *ReservationVoucher) () ([]byte, error) {:= uint64(.Expiration.Unix())return proto.Marshal(&pbv2.ReservationVoucher{Relay: []byte(.Relay),Peer: []byte(.Peer),Expiration: &,})}func ( *ReservationVoucher) ( []byte) error {:= pbv2.ReservationVoucher{}:= proto.Unmarshal(, &)if != nil {return}.Relay, = peer.IDFromBytes(.GetRelay())if != nil {return}.Peer, = peer.IDFromBytes(.GetPeer())if != nil {return}.Expiration = time.Unix(int64(.GetExpiration()), 0)return nil}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |