daemon: --bitcoind-poll=<seconds>

Speeds up testing significantly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-01-22 06:45:27 +10:30
parent 6443629f6a
commit 8f0e10309a
4 changed files with 14 additions and 5 deletions

View File

@ -84,6 +84,9 @@ static void config_register_opts(struct lightningd_state *dstate)
opt_register_arg("--min-commit-fee", opt_set_u64, opt_show_u64,
&dstate->config.commitment_fee_min,
"Minimum satoshis to accept for commitment transaction fee");
opt_register_arg("--bitcoind-poll", opt_set_u32, opt_show_u32,
&dstate->config.poll_seconds,
"Seconds between polling for new transactions");
}
static void default_config(struct config *config)
@ -110,6 +113,8 @@ static void default_config(struct config *config)
/* Don't accept less than double the current standard fee. */
config->commitment_fee_min = 10000;
config->poll_seconds = 30;
}
static struct lightningd_state *lightningd_state(void)

View File

@ -31,6 +31,9 @@ struct config {
/* How little are we prepared to have them pay? */
u64 commitment_fee_min;
/* How long (seconds) between polling bitcoind. */
u32 poll_seconds;
};
/* Here's where the global variables hide! */

View File

@ -31,8 +31,8 @@ LCLI2="../daemon/lightning-cli --lightning-dir=$DIR2"
trap "echo Results in $DIR1 and $DIR2" EXIT
mkdir $DIR1 $DIR2
$PREFIX1 ../daemon/lightningd --log-level=debug --lightning-dir=$DIR1 > $REDIR1 &
$PREFIX2 ../daemon/lightningd --log-level=debug --lightning-dir=$DIR2 > $REDIR2 &
$PREFIX1 ../daemon/lightningd --log-level=debug --bitcoind-poll=1 --lightning-dir=$DIR1 > $REDIR1 &
$PREFIX2 ../daemon/lightningd --log-level=debug --bitcoind-poll=1 --lightning-dir=$DIR2 > $REDIR2 &
i=0
while ! $LCLI1 getlog | grep Hello; do
@ -65,8 +65,8 @@ $LCLI2 getpeers | grep STATE_OPEN_WAITING_THEIRANCHOR
# Now make it pass anchor.
$CLI generate 3
# FIXME: Speed this up!
sleep 30
# They poll every second, so give them time to process.
sleep 2
$LCLI1 getpeers | grep STATE_NORMAL_HIGHPRIO
$LCLI2 getpeers | grep STATE_NORMAL_LOWPRIO

View File

@ -226,7 +226,8 @@ static void start_poll_transactions(struct lightningd_state *dstate)
void setup_watch_timer(struct lightningd_state *dstate)
{
init_timeout(&watch_timeout, 30, start_poll_transactions, dstate);
init_timeout(&watch_timeout, dstate->config.poll_seconds,
start_poll_transactions, dstate);
/* Run once immediately, in case there are issues. */
start_poll_transactions(dstate);
}