Skip to content

Commit 9357954

Browse files
committed
chanbackup: add spec quotes now we have this in the spec.
This is the only way to track spec changes in future. Signed-off-by: Rusty Russell <[email protected]>
1 parent f5b6b6f commit 9357954

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

plugins/chanbackup.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,16 @@ static struct command_result *peer_after_listdatastore(struct command *cmd,
386386
if (!peer_backup)
387387
return command_hook_success(cmd);
388388

389+
/* BOLT #1:
390+
* - If it does store the message:
391+
*...
392+
* - MUST send `peer_storage_retrieval` again after
393+
* reconnection, after exchanging `init` messages.
394+
*/
395+
/* BOLT #1:
396+
* The sender of `peer_storage_retrieval`:
397+
* - MUST include the last `blob` it stored for that peer.
398+
*/
389399
u8 *payload = towire_peer_storage_retrieval(cmd, hexdata);
390400

391401
plugin_log(cmd->plugin, LOG_DBG,
@@ -488,6 +498,15 @@ static struct command_result *after_listpeers(struct command *cmd,
488498
if (!peer_backup)
489499
return notification_or_hook_done(cmd);
490500

501+
/* BOLT #1:
502+
* The sender of `peer_storage`:
503+
* - MAY send `peer_storage` whenever necessary.
504+
* - MUST limit its `blob` to 65531 bytes.
505+
* - MUST encrypt the data in a manner that ensures its integrity
506+
* upon receipt.
507+
* - SHOULD pad the `blob` to ensure its length is always exactly 65531 bytes.
508+
*/
509+
/* FIXME: We do not pad! But this is because LDK doesn't store > 1k anyway */
491510
serialise_scb = towire_peer_storage(cmd,
492511
get_file_data(tmpctx, cmd->plugin));
493512

@@ -632,6 +651,13 @@ static struct command_result *failed_peer_restore(struct command *cmd,
632651
struct node_id *node_id,
633652
char *reason)
634653
{
654+
/* BOLT #1:
655+
*
656+
* The receiver of `peer_storage_retrieval`:
657+
* - when it receives `peer_storage_retrieval` with an outdated or irrelevant data:
658+
* - MAY send a warning.
659+
*/
660+
/* We don't, we just complain in the logs a little! */
635661
plugin_log(cmd->plugin, LOG_DBG, "PeerStorageFailed!: %s: %s",
636662
fmt_node_id(tmpctx, node_id),
637663
reason);
@@ -682,6 +708,21 @@ static struct command_result *handle_your_peer_storage(struct command *cmd,
682708
}
683709

684710
if (fromwire_peer_storage(cmd, payload, &payload_deserialise)) {
711+
/* BOLT #1:
712+
* The receiver of `peer_storage`:
713+
* - If it offered `option_provide_storage`:
714+
* - if it has an open channel with the sender:
715+
* - MUST store the message.
716+
* - MAY store the message anyway.
717+
*/
718+
/* FIXME: Only store peers we want to! */
719+
720+
/* BOLT #1:
721+
* - If it does store the message:
722+
* - MAY delay storage to ratelimit peer to no more than one
723+
* update per minute.
724+
* - MUST replace the old `blob` with the latest received.
725+
*/
685726
return jsonrpc_set_datastore_binary(cmd,
686727
tal_fmt(cmd,
687728
"chanbackup/peers/%s",

0 commit comments

Comments
 (0)