Browse Source

gossip_store: empty, don't truncate, on error.

Christian points out that we don't get spend notifications for old
channels if we truncate the store.  We'd need more work to do this,
either validating the channels are still unspent, or replaying old
blocks from the truncation point.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
57b38cac71
  1. 8
      gossipd/gossip_store.c

8
gossipd/gossip_store.c

@ -174,9 +174,13 @@ void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
truncate: truncate:
status_unusual("gossip_store: %s (%s) truncating to %"PRIu64, status_unusual("gossip_store: %s (%s) truncating to %"PRIu64,
bad, tal_hex(msg, msg), (u64)known_good); bad, tal_hex(msg, msg), (u64)1);
truncate_nomsg: truncate_nomsg:
if (ftruncate(gs->fd, known_good) != 0) /* FIXME: We would like to truncate to known_good, except we would
* miss channel_delete msgs. If we put block numbers into the store
* as we process them, we can know how far we need to roll back if we
* truncate the store */
if (ftruncate(gs->fd, 1) != 0)
status_failed(STATUS_FAIL_INTERNAL_ERROR, status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Truncating store: %s", strerror(errno)); "Truncating store: %s", strerror(errno));
out: out:

Loading…
Cancel
Save