mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
Protobuf does not allow naming conflicts for files within the same process, because all proto messages register themselves in a global registry. This is problematic because the server's itests import the client's looprpc package to make rpc queries to the loopd client, thus importing duplicate common.proto and server.proto from the client's looprc package (since they're both in there as well). This change moves the server's proto files into their own directory so that they are not imported when we want to use the client's files. We cannot change the package name for the server, because that would be a breaking change (the package name is included in URIS). Fortunately, we have the go_package option which allows us to place generated files in a different location.
33 lines
858 B
Go
33 lines
858 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/lightninglabs/loop/swapserverrpc"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
// validateRouteHints ensures that the Private flag isn't set along with
|
|
// the RouteHints flag. We don't allow both options to be set as these options
|
|
// are alternatives to each other. Private autogenerates hopHints while
|
|
// RouteHints are manually passed.
|
|
func validateRouteHints(ctx *cli.Context) ([]*swapserverrpc.RouteHint, error) {
|
|
var hints []*swapserverrpc.RouteHint
|
|
|
|
if ctx.IsSet(routeHintsFlag.Name) {
|
|
if ctx.IsSet(privateFlag.Name) {
|
|
return nil, fmt.Errorf(
|
|
"private and route_hints both set",
|
|
)
|
|
}
|
|
|
|
stringHints := []byte(ctx.String(routeHintsFlag.Name))
|
|
err := json.Unmarshal(stringHints, &hints)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unable to parse json: %v", err)
|
|
}
|
|
}
|
|
|
|
return hints, nil
|
|
}
|