Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Officeyutong
Copy link

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

@Officeyutong Officeyutong requested a review from a team as a code owner December 25, 2024 09:37
@Officeyutong Officeyutong requested review from zhangsoledad and removed request for a team December 25, 2024 09:37
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();
Copy link
Collaborator

@eval-exec eval-exec Dec 26, 2024

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

Copy link
Collaborator

@driftluo driftluo Dec 26, 2024

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 {
Copy link
Collaborator

@driftluo driftluo Dec 26, 2024

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.)

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants