Skip to main content

ThresholdRecommendations

Get close recommendations for currently open channels based whether they are below a set threshold.

Example request: http://localhost:8466/v1/faraday/threshold/UPTIME?rec_request.minimum_monitored=123

Source: faraday.proto

gRPC

rpc ThresholdRecommendations (ThresholdRecommendationsRequest) returns (CloseRecommendationsResponse);

REST

HTTP MethodPath
GET /v1/faraday/threshold/{rec_request.metric}

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:8465'
const MACAROON_PATH = 'FARADAY_DIR/regtest/faraday.macaroon'
const TLS_PATH = 'FARADAY_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('faraday.proto', loaderOptions);
const frdrpc = grpc.loadPackageDefinition(packageDefinition).frdrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new frdrpc.FaradayServer(GRPC_HOST, creds);
let request = {
rec_request: <CloseRecommendationRequest>,
threshold_value: <float>,
};
client.thresholdRecommendations(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "total_channels": <int32>,
// "considered_channels": <int32>,
// "recommendations": <Recommendation>,
// }

Messages

frdrpc.ThresholdRecommendationsRequest

Source: faraday.proto

FieldgRPC TypeREST TypeREST Placement
rec_request
CloseRecommendationRequestobjectmixed
threshold_value
floatnumberquery

frdrpc.CloseRecommendationsResponse

Source: faraday.proto

FieldgRPC TypeREST Type
total_channels
int32integer
considered_channels
int32integer
recommendations
Recommendation[]array

Nested Messages

frdrpc.CloseRecommendationRequest

FieldgRPC TypeREST Type
minimum_monitored
int64string
metric
Metricstring

frdrpc.Recommendation

FieldgRPC TypeREST Type
chan_point
stringstring
value
floatnumber
recommend_close
boolboolean

Enums

frdrpc.CloseRecommendationRequest.Metric

NameNumber
UNKNOWN
0
UPTIME
1
REVENUE
2
INCOMING_VOLUME
3
OUTGOING_VOLUME
4
TOTAL_VOLUME
5