-
Notifications
You must be signed in to change notification settings - Fork 902
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
Datastore #4674
Datastore #4674
Conversation
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.
LGTM, I have only a few comments
tests/test_misc.py
Outdated
|
||
l = l1.rpc.listdatastore() | ||
# Order is undefined! | ||
assert (l == {'datastore': [{'key': 'somekey', 'hex': somedata}, |
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.
I think this is the place where the code check will fail.
I a little bit difficult to guess what is the correct format of the {}
from the error message
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.
Yes, but it's always better to be explicit in tests, than loose. And it works :)
wallet/wallet.c
Outdated
struct db_stmt *stmt; | ||
|
||
/* Test if already exists. */ | ||
stmt = db_prepare_v2(w->db, SQL("SELECT 1" | ||
" FROM datastore" | ||
" WHERE key = ?;")); | ||
db_bind_text(stmt, 0, key); | ||
db_query_prepared(stmt); | ||
|
||
if (db_step(stmt)) { | ||
tal_free(stmt); | ||
return false; | ||
} |
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.
I don't know if I'm missing some things in the design of this functionality, but if a plugin needs to override functionality is it now possible with the current API of the wallet.h, right?
Do you think that is necessary use some additional parameters to the RPC command to give the possibility to override the propriety with key?
Somethings like lightning-cli datastore "fooo" "some" true
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.
Yes, since this isn't going to be in this release, I can revise this properly.
I am going to allow both hex and string arguments, and also allow a mode argument:
- "must-create", "must-replace", or "create-or-replace", "must-append", "create-or-append".
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.
I like this idea Rusty.
8d4e8e1
to
cdb0c3b
Compare
See ElementsProject/lightning#4674 (I manually tested that it passes all the tests there, too!) When they finally upgrade the node, this automatically puts any datastore data into the inbuilt datastore and shuts down. Signed-off-by: Rusty Russell <[email protected]>
See also lightningd/plugins#275 which provides this same functionality for previous versions! |
See ElementsProject/lightning#4674 (I manually tested that it passes all the tests there, too!) When they finally upgrade the node, this automatically puts any datastore data into the inbuilt datastore and shuts down. Signed-off-by: Rusty Russell <[email protected]>
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.
See ElementsProject/lightning#4674 (I manually tested that it passes all the tests there, too!) When they finally upgrade the node, this automatically puts any datastore data into the inbuilt datastore and shuts down. Signed-off-by: Rusty Russell <[email protected]>
Updated to add generation field, on suggestion from @shesek ! |
7463aa1
to
aba7728
Compare
aba7728
to
6b297f6
Compare
Trivial rebase to fix flake. |
6b297f6
to
8cf9e77
Compare
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]> Changelog-Added: JSON-RPC: `datastore`, `deldatastore` and `listdatastore` for plugins to store simple persistent key/value data.
Signed-off-by: Rusty Russell <[email protected]>
It's common, and the simplest case. Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
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 <[email protected]>
After some discussion with @shesek, and my own usage, we agreed that a more comprehensive interface, which explicitly supports grouping, is desirable. Thus keys are now arrays, with the semantic that a key is either a parent or has a value, never both. For convenience in the JSON schema, we always return them as arrays, though we accept simple strings as arguments. Signed-off-by: Rusty Russell <[email protected]>
c586d49
to
22da787
Compare
ACK 22da787 |
Closes #4525