Browse Source

chaintopology: always start 100 blocks back.

Since we panic when we see our root reorg out, even if we're not doing
anything yet, restoring the 100 block margin is the simplest fix.

Unfortunately this means adding a 100-block spacer in the tests, so things
don't get confused.

Fixes: #511
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
fb81e6c14b
  1. 7
      lightningd/chaintopology.c
  2. 5
      tests/test_lightningd.py

7
lightningd/chaintopology.c

@ -468,6 +468,13 @@ static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
if (blockcount < topo->first_blocknum)
topo->first_blocknum = blockcount;
/* FIXME: Because we don't handle our root disappearing, we go
* 100 blocks back */
if (topo->first_blocknum < 100)
topo->first_blocknum = 0;
else
topo->first_blocknum -= 100;
/* Get up to speed with topology. */
bitcoind_getblockhash(bitcoind, topo->first_blocknum,
get_init_block, topo);

5
tests/test_lightningd.py

@ -224,6 +224,11 @@ class BaseLightningDTests(unittest.TestCase):
if not ok:
raise Exception("At least one lightning exited with unexpected non-zero return code")
@classmethod
def tearDownClass(cls):
"""We need 100 blocks between runs, since otherwise they might see the txs from a previous run, and get very confused!"""
bitcoind.generate_block(100)
class LightningDTests(BaseLightningDTests):
def connect(self):
l1 = self.node_factory.get_node()

Loading…
Cancel
Save