Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ int main(int argc, char *argv[])

peer_first_blocknum = wallet_channels_first_blocknum(ld->wallet);

if (ld->config.from_blockheight > -1){
// Get_init_blockhash() go back of 100 blocks
peer_first_blocknum = ld->config.from_blockheight + 100;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that we want to start 100 blocks after the specified value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_init_blockhash starts 100 blocks behind the selected block. If it is more safe to always consider 100 blocks before the selected input block ( so the first "Adding block", in the log, starts 100 blocks before the specified blockheight in the option), I will remove this sum.

@cdecker cdecker Feb 14, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The + suggestes to me that if I specify height 500 this would start at 600 which is rather uexpected to me.

EDIT: Oh I see, it's compensating the -= 100 that we do in get_init_blockhash, I'd rather pull that subtraction out, instead of trying to compensate here.

}

db_commit_transaction(ld->wallet->db);

/* Initialize block topology (does its own transaction) */
Expand Down
3 changes: 3 additions & 0 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ struct config {
/* How long do we let them lock up our funds? (blocks) */
u32 locktime_max;

/* Add block from blockheight (-1 to use default chaintopology strategy). */
s32 from_blockheight;

@cdecker cdecker Feb 14, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a y43k bug in the making 😉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you suggest to use s64? or use a different default value?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just kidding :-)


/* How many blocks before we expect to see anchor?. */
u32 anchor_onchain_wait;

Expand Down
9 changes: 9 additions & 0 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ static void config_register_opts(struct lightningd *ld)
opt_register_arg("--max-locktime-blocks", opt_set_u32, opt_show_u32,
&ld->config.locktime_max,
"Maximum blocks a peer can lock up our funds");
opt_register_arg("--from-blockheight", opt_set_s32, opt_show_s32,
&ld->config.from_blockheight,
"Add blocks from blockchain height");
opt_register_arg("--anchor-onchain", opt_set_u32, opt_show_u32,
&ld->config.anchor_onchain_wait,
"Blocks before we give up on pending anchor transaction");
Expand Down Expand Up @@ -320,6 +323,9 @@ static const struct config testnet_config = {
/* They can have up to 3 days. */
.locktime_max = 3 * 6 * 24,

/* Default -1 to use default chaintopology strategy. */
.from_blockheight = -1,

/* Testnet can have long runs of empty blocks. */
.anchor_onchain_wait = 100,

Expand Down Expand Up @@ -373,6 +379,9 @@ static const struct config mainnet_config = {
/* They can have up to 3 days. */
.locktime_max = 3 * 6 * 24,

/* Default -1 to use default chaintopology strategy. */
.from_blockheight = -1,

/* You should get in within 10 blocks. */
.anchor_onchain_wait = 10,

Expand Down