frdrpcserver

package
v0.2.18-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 27 Imported by: 2

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

View Source
const Subsystem = "FRPC"

Subsystem defines the logging code for this subsystem.

Variables

View Source
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")
)
View Source
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

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

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

func NewRPCServer(cfg *Config) *RPCServer

NewRPCServer returns a new RPCServer backed by the given config.

func (*RPCServer) ChannelInsights

ChannelInsights returns the channel insights for our currently open set of channels.

func (*RPCServer) CloseReport

CloseReport returns a close report for the channel provided. Note that this endpoint requires connection to an external bitcoind node.

func (*RPCServer) ExchangeRate

ExchangeRate provides a fiat estimate for a set of timestamped bitcoin prices.

func (*RPCServer) ForwardingAbility

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

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

NodeAudit returns an on chain report for the period requested.

func (*RPCServer) OutlierRecommendations

OutlierRecommendations provides a set of close recommendations for the current set of open channels based on whether they are outliers.

func (*RPCServer) RevenueReport

RevenueReport returns a pairwise revenue report for a channel over the period requested.

func (*RPCServer) ThresholdRecommendations

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL