Merge pull request #8805 from breez/jssdwt-insert-edge-when-not-found

localchans: recreate missing edge if not found
This commit is contained in:
Oliver Gugger
2024-11-22 08:42:51 +01:00
committed by GitHub
12 changed files with 554 additions and 23 deletions

View File

@ -1118,12 +1118,31 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
ScidCloser: scidCloserMan,
}, nodeKeyDesc)
selfVertex := route.Vertex(nodeKeyDesc.PubKey.SerializeCompressed())
//nolint:lll
s.localChanMgr = &localchans.Manager{
ForAllOutgoingChannels: s.graphBuilder.ForAllOutgoingChannels,
SelfPub: nodeKeyDesc.PubKey,
DefaultRoutingPolicy: cc.RoutingPolicy,
ForAllOutgoingChannels: func(cb func(kvdb.RTx,
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy) error) error {
return s.graphDB.ForEachNodeChannel(selfVertex,
func(tx kvdb.RTx, c *models.ChannelEdgeInfo,
e *models.ChannelEdgePolicy,
_ *models.ChannelEdgePolicy) error {
// NOTE: The invoked callback here may
// receive a nil channel policy.
return cb(tx, c, e)
},
)
},
PropagateChanPolicyUpdate: s.authGossiper.PropagateChanPolicyUpdate,
UpdateForwardingPolicies: s.htlcSwitch.UpdateForwardingPolicies,
FetchChannel: s.chanStateDB.FetchChannel,
AddEdge: func(edge *models.ChannelEdgeInfo) error {
return s.graphBuilder.AddEdge(edge)
},
}
utxnStore, err := contractcourt.NewNurseryStore(