From 655ae90e5eb43b444156cc0f8feca8b133e48eaf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 22 Feb 2018 11:59:08 +1030 Subject: [PATCH] wallet: remove obsolete peers. Fixes: #1029 Signed-off-by: Rusty Russell --- wallet/db.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wallet/db.c b/wallet/db.c index 0270ba129..9d09dd8e5 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -196,6 +196,8 @@ char *dbmigrations[] = { "DELETE FROM channels WHERE state=1", /* Keep track of db ugprades, for debugging */ "CREATE TABLE db_upgrades (upgrade_from INTEGER, lightning_version TEXT);", + /* We used not to clean up peers when their channels were gone. */ + "DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);", NULL, };