mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
lnd+config_builder: add DependenciesReceiver
This commit is contained in:
parent
166be912c1
commit
b4be8c24f6
@ -44,6 +44,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/rpcwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"github.com/lightningnetwork/lnd/protofsm"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
@ -123,6 +124,32 @@ type ChainControlBuilder interface {
|
||||
*btcwallet.Config) (*chainreg.ChainControl, func(), error)
|
||||
}
|
||||
|
||||
// AliasAdder is an interface that can add SCID aliases to the local alias
|
||||
// store.
|
||||
type AliasAdder interface {
|
||||
// AddLocalAlias adds a database mapping from the passed alias to the
|
||||
// passed base SCID. The gossip boolean marks whether to create a
|
||||
// mapping that the gossiper will use. It is set to false for the
|
||||
// upgrade path where the feature-bit is toggled on and there are
|
||||
// existing channels. The linkUpdate flag is used to signal whether this
|
||||
// function should also trigger an update on the htlcswitch SCID alias
|
||||
// maps.
|
||||
AddLocalAlias(alias, baseScid lnwire.ShortChannelID, gossip,
|
||||
linkUpdate bool) error
|
||||
|
||||
// DeleteLocalAlias removes a mapping from the database and the
|
||||
// Manager's maps.
|
||||
DeleteLocalAlias(alias, baseScid lnwire.ShortChannelID) error
|
||||
}
|
||||
|
||||
// DependenciesReceiver is an interface that can be implemented by auxiliary
|
||||
// components that need to receive dependencies from lnd.
|
||||
type DependenciesReceiver interface {
|
||||
// RegisterComponents allows the auxiliary component to register the
|
||||
// given lnd components it might depend on.
|
||||
RegisterComponents(aliasAdder AliasAdder) error
|
||||
}
|
||||
|
||||
// ImplementationCfg is a struct that holds all configuration items for
|
||||
// components that can be implemented outside lnd itself.
|
||||
type ImplementationCfg struct {
|
||||
@ -182,6 +209,10 @@ type AuxComponents struct {
|
||||
// AuxDataParser is an optional data parser that can be used to parse
|
||||
// auxiliary data for certain custom channel types.
|
||||
AuxDataParser fn.Option[AuxDataParser]
|
||||
|
||||
// DependenciesReceiver is an optional endpoint to receive access to lnd
|
||||
// components once they are fully initialized.
|
||||
DependenciesReceiver fn.Option[DependenciesReceiver]
|
||||
}
|
||||
|
||||
// DefaultWalletImpl is the default implementation of our normal, btcwallet
|
||||
|
17
lnd.go
17
lnd.go
@ -25,6 +25,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/chanacceptor"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lncfg"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
@ -613,8 +614,20 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
||||
err)
|
||||
}
|
||||
|
||||
// Now we have created all dependencies necessary to populate and
|
||||
// start the RPC server.
|
||||
// Now we have created all dependencies necessary to register them with
|
||||
// the auxiliary components.
|
||||
err = fn.MapOptionZ(
|
||||
implCfg.DependenciesReceiver,
|
||||
func(r DependenciesReceiver) error {
|
||||
return r.RegisterComponents(server.aliasMgr)
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return mkErr("unable to add deps to aux components: %v", err)
|
||||
}
|
||||
|
||||
// And with those dependencies available, we can populate and start the
|
||||
// RPC server as well.
|
||||
err = rpcServer.addDeps(
|
||||
server, interceptorChain.MacaroonService(), cfg.SubRPCServers,
|
||||
atplManager, server.invoices, tower, multiAcceptor,
|
||||
|
Loading…
x
Reference in New Issue
Block a user