Documentation
¶
Overview ¶
Package frdrpcserver contains the server logic for faraday's grpc server which serves requests for close recommendations.
The Faraday server interface is implemented by the RPCServer struct. To keep this file readable, each function implemented by the interface has a file named after the function call which contains rpc parsing code for the request and response. If the call requires extensive additional logic, and unexported function with the same name should be created in this file as well.
Index ¶
- Constants
- Variables
- func UseLogger(logger btclog.Logger)
- type Config
- type ForwardingAnalyzer
- type RPCServer
- func (s *RPCServer) ChannelInsights(ctx context.Context, _ *frdrpc.ChannelInsightsRequest) (*frdrpc.ChannelInsightsResponse, error)
- func (s *RPCServer) CloseReport(ctx context.Context, req *frdrpc.CloseReportRequest) (*frdrpc.CloseReportResponse, error)
- func (s *RPCServer) ExchangeRate(ctx context.Context, req *frdrpc.ExchangeRateRequest) (*frdrpc.ExchangeRateResponse, error)
- func (s *RPCServer) ForwardingAbility(ctx context.Context, req *frdrpc.ForwardingAbilityRequest) (*frdrpc.ForwardingAbilityResponse, error)
- func (s *RPCServer) GetChannelEvents(ctx context.Context, req *frdrpc.ChannelEventsRequest) (*frdrpc.ChannelEventsResponse, error)
- func (s *RPCServer) NodeAudit(ctx context.Context, req *frdrpc.NodeAuditRequest) (*frdrpc.NodeAuditResponse, error)
- func (s *RPCServer) OutlierRecommendations(ctx context.Context, req *frdrpc.OutlierRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
- func (s *RPCServer) RevenueReport(ctx context.Context, req *frdrpc.RevenueReportRequest) (*frdrpc.RevenueReportResponse, error)
- func (s *RPCServer) ThresholdRecommendations(ctx context.Context, req *frdrpc.ThresholdRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
Constants ¶
const Subsystem = "FRPC"
Subsystem defines the logging code for this subsystem.
Variables ¶
var ( // ErrNoCategoryName is returned if a category does not have a name. ErrNoCategoryName = errors.New("category must have a name") // ErrSetChain is returned when on on/off chain boolean is set for // a category ErrSetChain = errors.New("category must be for on chain, off chain " + "or both") )
var ( // ErrBitcoinNodeRequired is required when an endpoint which requires // a bitcoin node backend is hit and we are not connected to one. ErrBitcoinNodeRequired = errors.New("bitcoin node required") )
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Lnd is a client which can be used to query lnd.
Lnd lndclient.LndServices
// ChanEvents is a database of channel events.
ChanEvents *chanevents.Store
// ForwardingAnalyzer computes forwarding-ability facts for the
// ForwardingAbility RPC. When nil, that endpoint returns
// codes.Unavailable.
ForwardingAnalyzer ForwardingAnalyzer
// BitcoinClient is an optional client which can be used to query
// on-chain data from a connected bitcoin node. If nil, faraday will
// not be able to serve endpoints which require on-chain data.
BitcoinClient chain.BitcoinClient
}
Config provides closures and settings required to run the rpc server.
type ForwardingAnalyzer ¶
type ForwardingAnalyzer interface {
EffectiveUptime(ctx context.Context, startTime, endTime time.Time,
liquidityFloor btcutil.Amount) (
map[chanevents.PeerPair]chanevents.ForwardingAbility, error)
}
ForwardingAnalyzer is the seam the RPC server uses to compute per-peer-pair forwarding facts. It is an interface so the handler can be exercised against a mock analyzer in tests.
type RPCServer ¶
type RPCServer struct {
// Required by the grpc-gateway/v2 library for forward compatibility.
frdrpc.UnimplementedFaradayServerServer
// contains filtered or unexported fields
}
RPCServer implements the faraday service, serving requests over grpc.
func NewRPCServer ¶
NewRPCServer returns a new RPCServer backed by the given config.
func (*RPCServer) ChannelInsights ¶
func (s *RPCServer) ChannelInsights(ctx context.Context, _ *frdrpc.ChannelInsightsRequest) (*frdrpc.ChannelInsightsResponse, error)
ChannelInsights returns the channel insights for our currently open set of channels.
func (*RPCServer) CloseReport ¶
func (s *RPCServer) CloseReport(ctx context.Context, req *frdrpc.CloseReportRequest) (*frdrpc.CloseReportResponse, error)
CloseReport returns a close report for the channel provided. Note that this endpoint requires connection to an external bitcoind node.
func (*RPCServer) ExchangeRate ¶
func (s *RPCServer) ExchangeRate(ctx context.Context, req *frdrpc.ExchangeRateRequest) (*frdrpc.ExchangeRateResponse, error)
ExchangeRate provides a fiat estimate for a set of timestamped bitcoin prices.
func (*RPCServer) ForwardingAbility ¶
func (s *RPCServer) ForwardingAbility(ctx context.Context, req *frdrpc.ForwardingAbilityRequest) ( *frdrpc.ForwardingAbilityResponse, error)
ForwardingAbility returns the raw effective-uptime and forwarded-volume facts for each peer pair over the requested window. An unset end_time defaults to the current time and an unset liquidity_floor_sat to defaultLiquidityFloorSat.
func (*RPCServer) GetChannelEvents ¶
func (s *RPCServer) GetChannelEvents(ctx context.Context, req *frdrpc.ChannelEventsRequest) (*frdrpc.ChannelEventsResponse, error)
GetChannelEvents serves a paginated read of a channel's events. A zero end_time defaults to the server's current time, max_events is clamped to the server's hard cap, and an unknown channel point yields NotFound.
func (*RPCServer) NodeAudit ¶
func (s *RPCServer) NodeAudit(ctx context.Context, req *frdrpc.NodeAuditRequest) (*frdrpc.NodeAuditResponse, error)
NodeAudit returns an on chain report for the period requested.
func (*RPCServer) OutlierRecommendations ¶
func (s *RPCServer) OutlierRecommendations(ctx context.Context, req *frdrpc.OutlierRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
OutlierRecommendations provides a set of close recommendations for the current set of open channels based on whether they are outliers.
func (*RPCServer) RevenueReport ¶
func (s *RPCServer) RevenueReport(ctx context.Context, req *frdrpc.RevenueReportRequest) (*frdrpc.RevenueReportResponse, error)
RevenueReport returns a pairwise revenue report for a channel over the period requested.
func (*RPCServer) ThresholdRecommendations ¶
func (s *RPCServer) ThresholdRecommendations(ctx context.Context, req *frdrpc.ThresholdRecommendationsRequest) (*frdrpc.CloseRecommendationsResponse, error)
ThresholdRecommendations provides a set of close recommendations for the current set of open channels based on whether they are above or below a given threshold.