@@ -162,6 +162,7 @@ struct sql {
162162 int gosstore_fd ;
163163 size_t gosstore_nodes_off , gosstore_channels_off ;
164164 u64 next_rowid ;
165+ u32 limit_per_list ;
165166
166167 /* This is an aux_command for all our watches */
167168 struct command * waitcmd ;
@@ -1715,14 +1716,13 @@ static const char *db_table_name(const tal_t *ctx, const char *cmdname)
17151716 return ret ;
17161717}
17171718
1718- #define LIMIT_PER_LIST 10000
1719-
17201719static struct command_result * limited_list_done (struct command * cmd ,
17211720 const char * method ,
17221721 const char * buf ,
17231722 const jsmntok_t * result ,
17241723 struct db_query * dbq )
17251724{
1725+ struct sql * sql = sql_of (dbq -> cmd -> plugin );
17261726 struct table_desc * td = dbq -> tables [0 ];
17271727 struct command_result * ret ;
17281728 size_t num_entries ;
@@ -1735,14 +1735,15 @@ static struct command_result *limited_list_done(struct command *cmd,
17351735 return ret ;
17361736
17371737 /* If we got the number we asked for, we need to ask again. */
1738- return one_refresh_done (cmd , dbq , num_entries == LIMIT_PER_LIST );
1738+ return one_refresh_done (cmd , dbq , num_entries == sql -> limit_per_list );
17391739}
17401740
17411741/* The simplest case: append-only lists */
17421742static struct command_result * refresh_by_created_index (struct command * cmd ,
17431743 struct table_desc * td ,
17441744 struct db_query * dbq )
17451745{
1746+ struct sql * sql = sql_of (dbq -> cmd -> plugin );
17461747 struct out_req * req ;
17471748
17481749 /* Since we're relying on watches, mark refreshing unnecessary to start */
@@ -1754,7 +1755,7 @@ static struct command_result *refresh_by_created_index(struct command *cmd,
17541755 dbq );
17551756 json_add_string (req -> js , "index" , "created" );
17561757 json_add_u64 (req -> js , "start" , td -> last_created_index + 1 );
1757- json_add_u64 (req -> js , "limit" , LIMIT_PER_LIST );
1758+ json_add_u64 (req -> js , "limit" , sql -> limit_per_list );
17581759 return send_outreq (req );
17591760}
17601761
@@ -2216,11 +2217,16 @@ int main(int argc, char *argv[])
22162217 sql -> gosstore_fd = -1 ;
22172218 sql -> gosstore_nodes_off = sql -> gosstore_channels_off = 0 ;
22182219 sql -> next_rowid = 1 ;
2220+ sql -> limit_per_list = 10000 ;
22192221 plugin_main (argv , init , take (sql ), PLUGIN_RESTARTABLE , true, NULL , commands , ARRAY_SIZE (commands ),
22202222 NULL , 0 , NULL , 0 , NULL , 0 ,
22212223 plugin_option_dev ("dev-sqlfilename" ,
22222224 "string" ,
22232225 "Use on-disk sqlite3 file instead of in memory (e.g. debugging)" ,
22242226 charp_option , NULL , & sql -> dbfilename ),
2227+ plugin_option_dev ("dev-sqllistlimit" ,
2228+ "int" ,
2229+ "A variable setting for how many chainmoves/channelmoves we fetch at once" ,
2230+ u32_option , NULL , & sql -> limit_per_list ),
22252231 NULL );
22262232}
0 commit comments