Skip to content

Commit c15cf58

Browse files
committed
zombierecovery: check if node is in list of known ancients
1 parent b00bf50 commit c15cf58

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

cmd/chantools/zombierecovery_findmatches.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ func (c *zombieRecoveryFindMatchesCommand) Execute(_ *cobra.Command,
197197
"https://api.amboss.space/graphql", httpClient,
198198
)
199199

200+
// Find ancient channels first.
201+
err = ancientChannelsForNodes(registrations)
202+
if err != nil {
203+
log.Errorf("Error finding ancient channels, ignoring: %v", err)
204+
}
205+
200206
// Loop through all nodes now.
201207
matches := make(map[string]map[string]*match)
202208
idx := 0
@@ -396,3 +402,27 @@ func identifyPeer(channel *gqChannel, node1 string) string {
396402

397403
panic("peer not found")
398404
}
405+
406+
func ancientChannelsForNodes(registrations map[string]string) error {
407+
var channels []ancientChannel
408+
err := json.Unmarshal(ancientChannelPoints, &channels)
409+
if err != nil {
410+
return err
411+
}
412+
413+
for node, contact := range registrations {
414+
var numUnspent uint64
415+
for _, entry := range channels {
416+
if entry.Node == node {
417+
numUnspent++
418+
}
419+
}
420+
421+
if numUnspent > 0 {
422+
log.Infof("Node %s (%s) has %d ancient unspent "+
423+
"channels", node, contact, numUnspent)
424+
}
425+
}
426+
427+
return nil
428+
}

0 commit comments

Comments
 (0)