datastore: add generation, simple atomicity.

We add a generation counter, and allow update or del conditional
on a given generation.

Formalizes error codes, too, since we have more now.

Suggested-by: @shesek
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-08-25 12:21:04 +09:30
committed by Christian Decker
parent 432508e65e
commit 533571a655
18 changed files with 241 additions and 117 deletions

View File

@@ -86,6 +86,13 @@ static const errcode_t OFFER_ROUTE_NOT_FOUND = 1003;
static const errcode_t OFFER_BAD_INVREQ_REPLY = 1004;
static const errcode_t OFFER_TIMEOUT = 1005;
/* Errors from datastore command */
static const errcode_t DATASTORE_DEL_DOES_NOT_EXIST = 1200;
static const errcode_t DATASTORE_DEL_WRONG_GENERATION = 1201;
static const errcode_t DATASTORE_UPDATE_ALREADY_EXISTS = 1202;
static const errcode_t DATASTORE_UPDATE_DOES_NOT_EXIST = 1203;
static const errcode_t DATASTORE_UPDATE_WRONG_GENERATION = 1204;
/* Errors from wait* commands */
static const errcode_t WAIT_TIMEOUT = 2000;