-
Notifications
You must be signed in to change notification settings - Fork 235
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-store, wasm: use path
as database name in wasm peer-store implementation
#4760
base: develop
Are you sure you want to change the base?
peer-store, wasm: use path
as database name in wasm peer-store implementation
#4760
Conversation
let store_name = path.as_ref().to_str().unwrap().to_owned(); | ||
let store_name_clone = store_name.clone(); | ||
let database_name = path.as_ref().to_str().unwrap().to_owned(); | ||
let mut open_request = factory.open(&database_name, Some(1)).unwrap(); |
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.
There is a secret_key
file in network
dir. If the secret key in CKB's network directory changes, it may cause the NodeId
to change as well. Is this expected? Cc. @driftluo
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.
No, wasm target‘s secret_key isn't stored on this path. The user manually passes it to ckb
@@ -67,15 +69,14 @@ pub struct Storage { | |||
impl Storage { | |||
pub async fn new<P: AsRef<Path>>(path: P) -> Self { |
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.
The path needs to be added with the network name. No matter what network is passed in, the same path is used now.
By the way,if we use network
with DB name, a different path as the object store name, is it ok?(I think the current problem is that the path is the same value regardless of the network.)
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.
- For the first question, the user can customize store path in network configuration to make different network use different databases
- For the second, IndexedDB limits store creation only to the time of upgrading database, if we want to use different stores for different configurations, we'll need a suitable way to determine database version
What problem does this PR solve?
In the original peer store implementation of wasm , there is only one database (in IndexedDB) to store all peers, different network configurations are distinguished by store names, this can cause one issue: There is no way to use multiple configurations after the database was created, since IndexedDB disallows creating stores unless there is an upgrade for a certain database.
What is changed and how it works?
What's Changed:
This PR updates peer store implementation on wasm, to use database names to distinguish different configurations, and database names comes from
path
section in network configuration, so makes it possible to switch network configurations in the same website