-
Notifications
You must be signed in to change notification settings - Fork 14
feat: sign message #106
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
feat: sign message #106
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| use crate::context::AppContext; | ||
| use crate::database::Database; | ||
| use crate::model::qualified_identity::QualifiedIdentity; | ||
| use crate::model::wallet::Wallet; | ||
| use crate::model::wallet::{Wallet, WalletSeedHash}; | ||
| use dash_sdk::dpp::identity::accessors::IdentityGettersV0; | ||
| use dash_sdk::platform::Identifier; | ||
| use rusqlite::params; | ||
| use std::collections::BTreeMap; | ||
| use std::sync::{Arc, RwLock}; | ||
| use std::sync::{Arc, RwLock, RwLockReadGuard}; | ||
|
|
||
| impl Database { | ||
| /// Updates the alias of a specified identity. | ||
|
|
@@ -163,7 +163,7 @@ impl Database { | |
| pub fn get_local_qualified_identities( | ||
| &self, | ||
| app_context: &AppContext, | ||
| wallets: &[Arc<RwLock<Wallet>>], | ||
| wallets: &BTreeMap<WalletSeedHash, Arc<RwLock<Wallet>>>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider optimizing wallet association to avoid full map cloning The current implementation clones the entire wallets map for each identity, which could be inefficient. The TODO comment correctly identifies this concern. Consider these improvements: - identity.associated_wallets = wallets.clone(); //todo: use less wallets
+ // Only associate wallets that are relevant to this identity
+ identity.associated_wallets = if let Some(wallet_index) = identity.wallet_index {
+ wallets.iter()
+ .filter(|(_, wallet)| {
+ // Add your filtering logic here based on wallet_index
+ // This is a placeholder - implement actual wallet matching logic
+ true
+ })
+ .map(|(k, v)| (k.clone(), v.clone()))
+ .collect()
+ } else {
+ BTreeMap::new()
+ };This approach would:
Please implement the appropriate filtering logic based on your wallet matching requirements. Also applies to: 192-192 |
||
| ) -> rusqlite::Result<Vec<QualifiedIdentity>> { | ||
| let network = app_context.network_string(); | ||
|
|
||
|
|
@@ -189,10 +189,7 @@ impl Database { | |
| identity.wallet_index = wallet_index; | ||
|
|
||
| // Associate wallets | ||
| identity.associated_wallets = wallets | ||
| .iter() | ||
| .map(|wallet| (wallet.read().unwrap().seed_hash(), wallet.clone())) | ||
| .collect(); | ||
| identity.associated_wallets = wallets.clone(); //todo: use less wallets | ||
|
|
||
| // Retrieve the identity_id as bytes | ||
| let identity_id = identity.identity.id().to_buffer(); | ||
|
|
||
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.
🛠️ Refactor suggestion
Consider improving error handling in wallet initialization.
While the conversion to BTreeMap is implemented correctly, the use of
expectcould cause panic in production. Consider propagating the error instead.