Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Merge ACL whitelist #123

Merged
merged 5 commits into from
Mar 7, 2024
Merged

Merge ACL whitelist #123

merged 5 commits into from
Mar 7, 2024

Conversation

musitdev
Copy link
Contributor

@musitdev musitdev commented Mar 5, 2024

I let the code in the network module. Not sure where to put it.
I define the merge function alone so that I can test it without the db and network.
I put some rules about the merge:

  • if a pubkey fail to parse skip it and continue the merge without it.
  • if the network fetches fail for one line, abort and do nothing.
  • if the new acl key list is empty, do nothing instead of removing all the keys.

@tuommaki tuommaki changed the title Merge whishlist Merge ACL whitelist Mar 6, 2024
Copy link
Contributor

@tuommaki tuommaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general the code looks good, but I think the DB query requires changes.

crates/node/src/networking/mod.rs Outdated Show resolved Hide resolved
crates/node/src/networking/mod.rs Outdated Show resolved Hide resolved
crates/node/src/networking/mod.rs Outdated Show resolved Hide resolved
@@ -535,6 +535,14 @@ impl Database {
Ok(())
}

pub async fn get_acl_whitelist(&self) -> Result<Vec<entity::PublicKey>> {
let dbkey_set: Vec<entity::PublicKey> = sqlx::query("SELECT 1 FROM acl_whitelist")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? This query returns literal 1 for each row that exists in the DB. I'd expect this to yield error when trying to parse as public key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I copy and paste from another query. I thought the 1 was interpreted as a prepared statement, the first return field. I didn't test the read in fact because I start only one time.
I correct and to a read test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've to add a test too, when the public key parse fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've corrected the query and added the test.

Copy link
Contributor

@tuommaki tuommaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Please apply the typo fix for the variable name 😉

@musitdev
Copy link
Contributor Author

musitdev commented Mar 7, 2024

Done I merge

@musitdev musitdev merged commit 2bee40f into main Mar 7, 2024
4 checks passed
@musitdev musitdev deleted the merge_whishlist branch March 7, 2024 09:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants