lnd: implement new Quiesce RPC with link operation stub

This commit is contained in:
Keagan McClelland 2024-03-12 12:16:01 -07:00
parent 99f5ca4018
commit a085b59814
No known key found for this signature in database
GPG Key ID: FA7E65C951F12439
3 changed files with 32 additions and 0 deletions

View File

@ -6,6 +6,7 @@ package devrpc
import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch"
)
// Config is the primary configuration struct for the DEV RPC server. It
@ -16,4 +17,5 @@ import (
type Config struct {
ActiveNetParams *chaincfg.Params
GraphDB *channeldb.ChannelGraph
Switch *htlcswitch.Switch
}

View File

@ -40,6 +40,10 @@ var (
Entity: "offchain",
Action: "write",
}},
"/devrpc.Dev/Quiesce": {{
Entity: "offchain",
Action: "write",
}},
}
)
@ -342,3 +346,25 @@ func (s *Server) ImportGraph(ctx context.Context,
return &ImportGraphResponse{}, nil
}
// Quiesce initiates the quiescence process for the channel with the given
// channel ID. This method will block until the channel is fully quiesced.
func (s *Server) Quiesce(_ context.Context, in *QuiescenceRequest) (
*QuiescenceResponse, error) {
txid, err := lnrpc.GetChanPointFundingTxid(in.ChanId)
if err != nil {
return nil, err
}
op := wire.NewOutPoint(txid, in.ChanId.OutputIndex)
cid := lnwire.NewChanIDFromOutPoint(*op)
_, err = s.cfg.Switch.GetLink(cid)
if err != nil {
return nil, err
}
// TODO(proofofkeags): Add Link operation for initiating quiescence and
// implement the rest of this in those terms
return nil, fmt.Errorf("TODO(proofofkeags): Implement")
}

View File

@ -346,6 +346,10 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
reflect.ValueOf(graphDB),
)
subCfgValue.FieldByName("Switch").Set(
reflect.ValueOf(htlcSwitch),
)
case *peersrpc.Config:
subCfgValue := extractReflectValue(subCfg)