zombierecovery: check if node is in list of known ancients

This commit is contained in:
Oliver Gugger 2025-02-21 15:27:21 +01:00
parent b00bf505e0
commit c15cf58895
No known key found for this signature in database
GPG key ID: 8E4256593F177720

View file

@ -197,6 +197,12 @@ func (c *zombieRecoveryFindMatchesCommand) Execute(_ *cobra.Command,
"https://api.amboss.space/graphql", httpClient,
)
// Find ancient channels first.
err = ancientChannelsForNodes(registrations)
if err != nil {
log.Errorf("Error finding ancient channels, ignoring: %v", err)
}
// Loop through all nodes now.
matches := make(map[string]map[string]*match)
idx := 0
@ -396,3 +402,27 @@ func identifyPeer(channel *gqChannel, node1 string) string {
panic("peer not found")
}
func ancientChannelsForNodes(registrations map[string]string) error {
var channels []ancientChannel
err := json.Unmarshal(ancientChannelPoints, &channels)
if err != nil {
return err
}
for node, contact := range registrations {
var numUnspent uint64
for _, entry := range channels {
if entry.Node == node {
numUnspent++
}
}
if numUnspent > 0 {
log.Infof("Node %s (%s) has %d ancient unspent "+
"channels", node, contact, numUnspent)
}
}
return nil
}