Browse Source

db: Create table for HTLCs

Also added a small warning to one of the used enums not to reorder or
insert values. They'd break the update path.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
3dda72c885
  1. 4
      common/htlc_state.h
  2. 19
      wallet/db.c

4
common/htlc_state.h

@ -2,6 +2,10 @@
#define LIGHTNING_COMMON_HTLC_STATE_H
#include "config.h"
/*
* /!\ The generated enum values are used in the database, DO NOT
* reorder or insert new values (appending at the end is ok) /!\
*/
enum htlc_state {
/* When we add a new htlc, it goes in this order. */
SENT_ADD_HTLC,

19
wallet/db.c

@ -92,6 +92,25 @@ char *dbmigrations[] = {
" max_accepted_htlcs INTEGER,"
" PRIMARY KEY (id)"
");",
"CREATE TABLE channel_htlcs ("
" id INTEGER,"
" channel_id INTEGER REFERENCES channels(id) ON DELETE CASCADE,"
" channel_htlc_id INTEGER,"
" direction INTEGER,"
" origin_htlc INTEGER,"
" msatoshi INTEGER,"
" ctlv_expiry INTEGER,"
" payment_hash BLOB,"
" payment_key BLOB,"
" routing_onion BLOB,"
" failuremsg BLOB,"
" malformed_onion INTEGER,"
" hstate INTEGER,"
" shared_secret BLOB,"
" preimage BLOB,"
" PRIMARY KEY (id),"
" UNIQUE (channel_id, channel_htlc_id, direction)"
");",
NULL,
};

Loading…
Cancel
Save