-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Peer channel split, so we can sanely allow a peer to reopen a channel while others are closed #975
Changes from 5 commits
102a591
677d2a0
f937b71
5e0123c
b10cf34
2d959d2
8e25301
b41087d
84becaf
018c93a
fefb026
544f676
6d63093
8704434
e0eb5f0
32293ed
9d16fa5
ea40ebe
afa19c5
c983225
383afe8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,11 @@ | |
#define DIRECTION_INCOMING 0 | ||
#define DIRECTION_OUTGOING 1 | ||
|
||
struct wallet *wallet_new(const tal_t *ctx, | ||
struct wallet *wallet_new(struct lightningd *ld, | ||
struct log *log, struct timers *timers) | ||
{ | ||
struct wallet *wallet = tal(ctx, struct wallet); | ||
struct wallet *wallet = tal(ld, struct wallet); | ||
wallet->ld = ld; | ||
wallet->db = db_setup(wallet, log); | ||
wallet->log = log; | ||
wallet->bip32_base = NULL; | ||
|
@@ -625,9 +626,16 @@ static const char *channel_fields = | |
bool wallet_channels_load_active(const tal_t *ctx, struct wallet *w, struct list_head *peers) | ||
{ | ||
bool ok = true; | ||
sqlite3_stmt *stmt; | ||
|
||
/* Get rid of OPENINGD entries; they don't last across reconnects */ | ||
stmt = db_prepare(w->db, "DELETE FROM channels WHERE state=?"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should really be a migration and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's in a future patch. For the moment we still put opening channels in the DB, so this is needed. |
||
sqlite3_bind_int64(stmt, 1, OPENINGD); | ||
db_exec_prepared(w->db, stmt); | ||
|
||
/* Channels are active if they have reached at least the | ||
* opening state and they are not marked as complete */ | ||
sqlite3_stmt *stmt = db_query( | ||
stmt = db_query( | ||
__func__, w->db, "SELECT %s FROM channels WHERE state > %d AND state != %d;", | ||
channel_fields, OPENINGD, CLOSINGD_COMPLETE); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this also mean we delete all channels from the DB on a clean shutdown? That'd definitely be undesirable.
I prefer having an explicit call to
wallet_channel_delete
when we're sure we want to forget about the channel, rather than have this hidden DB change in a destructor anyway.