-
Notifications
You must be signed in to change notification settings - Fork 229
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
refactor StorageNode type #5945
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.
I like the overall direction, but would prefer to keep the ChainStorageNode
type rather than StorageNode
(to indicate the dependency upon chain storage semantics).
Also, since you're doing this, how about moving the type definition from packages/notifier/src/types.js to a more logical home, and also providing a definition of what instances of the type represent (e.g., "a node in a hierarchical externally-reachable storage structure that identifies children by restricted ASCII name and is associated with arbitrary string-valued data defaulting to the empty string")?
* @returns {Promise<StorageNode>} | ||
*/ | ||
export async function makeStorageNode(chainStorage, childName) { | ||
export async function makeStorageNodeChild(chainStorage, childName) { |
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 support this rename, and would recommend taking it farther:
export async function makeStorageNodeChild(chainStorage, childName) { | |
export async function makeStorageNodeChild(storageNode, childName) { |
clearValue() { | ||
handleStorageMessage({ key: path, method: 'set' }); | ||
}, |
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.
This is a hard pill to swallow because there ought to be a conceptual difference between "set to empty" vs. "unset", but factually that is not the case in vstorage.go. So I do not object.
@@ -68,7 +75,7 @@ test('makeChainStorageRoot', async t => { | |||
); | |||
} | |||
|
|||
rootNode.clearValue(); | |||
rootNode.setValue(undefined); |
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.
This call is invalid.
rootNode.setValue(undefined); | |
rootNode.setValue(''); |
@@ -172,22 +173,22 @@ test('makeChainStorageRoot', async t => { | |||
'level-skipping setValue message', | |||
); | |||
|
|||
childNode.clearValue(); | |||
childNode.setValue(undefined); |
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.
childNode.setValue(undefined); | |
childNode.setValue(''); |
); | ||
deepNode.clearValue(); | ||
deepNode.setValue(undefined); |
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.
deepNode.setValue(undefined); | |
deepNode.setValue(''); |
); | ||
childNode.clearValue(); | ||
childNode.setValue(undefined); |
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.
childNode.setValue(undefined); | |
childNode.setValue(''); |
86e7bfd
to
48754ea
Compare
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.
Thanks!
packages/notifier/src/types.js
Outdated
* | ||
* Vstorage is a hierarchical externally-reachable storage structure that | ||
* identifies children by restricted ASCII name and is associated with arbitrary | ||
* string-valued data defaulting to the empty string. |
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.
* string-valued data defaulting to the empty string. | |
* string-valued data for each node, defaulting to the empty string. |
getStoreKey() { | ||
return handleStorageMessage({ key: path, method: 'getStoreKey' }); | ||
}, | ||
getChildNode(name) { | ||
/** @type {(name: string) => VStorageNode} */ | ||
makeChildNode(name) { |
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.
In Agoric conventions that I learned in the past few weeks, I think the most appropriate name for this method is provideChildNode
("provide" referring to operations that return a value after creating it if necessary, acknowledging that it might have already existed).
And likewise for makeStorageNodeChild
.
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 with provide
you get the same object on repeated requests. The two methods you suggest renaming actually call makeChainStorageNode
which always makes a fresh node. Changing that is out of scope but I can follow up to do that. WDYT @michaelfig ?
I just noticed agoric-sdk/packages/casting/src/casting-spec.js Lines 44 to 48 in a457f75
StorageNode .
@michaelfig are there meant to be more than one backing of |
8e4cad2
to
a656966
Compare
37430c8
to
e1e196c
Compare
@Mergifyio unqueue |
✅ The pull request has been removed from the queue |
@Mergifyio queue |
Sorry but I didn't understand the arguments of the command |
@Mergifyio refresh |
✅ Pull request refreshed |
@Mergifyio queue master |
Sorry but I didn't understand the arguments of the command |
e1e196c
to
7d56fa8
Compare
7d56fa8
to
a67d808
Compare
Description
We have ChainStorageNode and StorageNode but it seems the latter is sufficient. The only difference is the former has
clearValue
, which is the same assetValue(undefined)
.This removes
clearValue
and replacesChainStorageNode
withStorageNode
.It also renames the
makeStorageNode
function to distinguish its use case (making a child) and makeschildName
required.Security Considerations
--
Documentation Considerations
--
Testing Considerations
CI