From 1b67d521c1c3bcb615aa15e314e1ce71e1ffa836 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 20 Aug 2020 21:12:38 +0930 Subject: [PATCH] db: remove assertion on validity of node_ids read from db. We've never hit this, we do check them on insert, and it's slowing down some operations unnecessarily. $ time lightning-cli -R --network=regtest --lightning-dir /tmp/ltests-k8jhvtty/test_pay_stress_1/lightning-1/ listpays > /dev/null Before: real 0m1.781s user 0m0.127s sys 0m0.013s After: real 0m1.545s user 0m0.124s sys 0m0.024s Also, the raw listsendpays drops from 0.983s to 0.676s. (With -O3 -flto, listsendpays is 0.416s, listpays 0.971s). Signed-off-by: Rusty Russell --- wallet/db.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/wallet/db.c b/wallet/db.c index 07b3864a104f..0c1560e1b243 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -1498,7 +1498,6 @@ void db_column_node_id(struct db_stmt *stmt, int col, struct node_id *dest) { assert(db_column_bytes(stmt, col) == sizeof(dest->k)); memcpy(dest->k, db_column_blob(stmt, col), sizeof(dest->k)); - assert(node_id_valid(dest)); } struct node_id *db_column_node_id_arr(const tal_t *ctx, struct db_stmt *stmt, @@ -1510,11 +1509,8 @@ struct node_id *db_column_node_id_arr(const tal_t *ctx, struct db_stmt *stmt, assert(n * sizeof(ret->k) == (size_t)db_column_bytes(stmt, col)); ret = tal_arr(ctx, struct node_id, n); - for (size_t i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) memcpy(ret[i].k, arr + i * sizeof(ret[i].k), sizeof(ret[i].k)); - if (!node_id_valid(&ret[i])) - return tal_free(ret); - } return ret; }