The Go implementation of the circuit relay v2 implementation treats the
`Reservation::expire` field as `required`:
``` Golang
result := &Reservation{}
result.Expiration = time.Unix(int64(rsvp.GetExpire()), 0)
if result.Expiration.Before(time.Now()) {
return nil, fmt.Errorf("received reservation with expiration date in the past: %s", result.Expiration)
}
```
bfee9f5935/p2p/protocol/circuitv2/client/reservation.go (L88-L92)
Where `rsvp.GetExpire` returns `0` when `Reservation::expire` is not set:
``` Golang
func (m *Reservation) GetExpire() uint64 {
if m != nil && m.Expire != nil {
return *m.Expire
}
return 0
}
```
bfee9f5935/p2p/protocol/circuitv2/pb/circuit.pb.go (L414-L419)
While inexplicable to me why Go treats the non-set case equal to the default
value (`0`), we unfortunately have to take the go implementation as the source
of truth, given that it is already released.
With the above in mind and to prevent confusion for other implementations in
languages which do not treat the non-set case equal to the default value (`0`),
this commit marks the `Reservation::expire` field as `required`.
* Specify the Circuit Relay v2 protocol.
* Move README.md specifying the Circuit Relay v1 protocol to circuit-v1.md
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: raulk <raul@protocol.ai>