2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-17 21:25:56 +00:00
loop/staticaddr/version/protocol_version.go
2024-05-23 15:12:18 +02:00

49 lines
1.4 KiB
Go

package version
import (
looprpc "github.com/lightninglabs/loop/swapserverrpc"
)
// AddressProtocolVersion represents the protocol version (declared on rpc
// level) that the client declared to us.
type AddressProtocolVersion uint32
const (
// ProtocolVersion_V0 indicates that the client is a legacy version
// that did not report its protocol version.
ProtocolVersion_V0 AddressProtocolVersion = 0
// stableRPCProtocolVersion defines the current stable RPC protocol
// version.
stableRPCProtocolVersion = looprpc.StaticAddressProtocolVersion_V0
)
var (
// currentRPCProtocolVersion holds the version of the RPC protocol
// that the client selected to use for new swaps. Shouldn't be lower
// than the previous protocol version.
currentRPCProtocolVersion = stableRPCProtocolVersion
)
// CurrentRPCProtocolVersion returns the RPC protocol version selected to be
// used for new swaps.
func CurrentRPCProtocolVersion() looprpc.StaticAddressProtocolVersion {
return currentRPCProtocolVersion
}
// Valid returns true if the value of the AddressProtocolVersion is valid.
func (p AddressProtocolVersion) Valid() bool {
return p <= AddressProtocolVersion(stableRPCProtocolVersion)
}
// String returns the string representation of a protocol version.
func (p AddressProtocolVersion) String() string {
switch p {
case ProtocolVersion_V0:
return "V0"
default:
return "Unknown"
}
}