channeldb+server: prune link nodes on startup
In this commit, we extend the server's functionality to prune link nodes on startup. Since we currently only decide whether to prune a link node from the database based on a channel close, it's possible that we have link nodes lingering from before this functionality was added on.
This commit is contained in:
2 files changed
+26
-1
No files matched your search
@@ -630,6 +630,26 @@ func (db *DB) pruneLinkNode(tx *bolt.Tx, remotePub *btcec.PublicKey) error {
|
||||
return db.deleteLinkNode(tx, remotePub)
|
||||
}
|
||||
|
||||
// PruneLinkNodes attempts to prune all link nodes found within the databse with
|
||||
// whom we no longer have any open channels with.
|
||||
func (db *DB) PruneLinkNodes() error {
|
||||
return db.Update(func(tx *bolt.Tx) error {
|
||||
linkNodes, err := db.fetchAllLinkNodes(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, linkNode := range linkNodes {
|
||||
err := db.pruneLinkNode(tx, linkNode.IdentityPub)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// syncVersions function is used for safe db version synchronization. It
|
||||
// applies migration functions to the current database and recovers the
|
||||
// previous state of db if at least one error/panic appeared during migration.
|
||||
|
||||
Reference in new issue
Block a user