Coder Social home page Coder Social logo

Comments (6)

slawlor avatar slawlor commented on April 19, 2024

@eozturk1 was this solved with #102 ?

from akd.

eozturk1 avatar eozturk1 commented on April 19, 2024

Unfortunately, no.

Debugging this, it seems this error originates from direction to the leaf as well as to self being None. I am not sure whether there are any other cases though. Any other ideas on how we could identify duplicate nodes/elements?

--
To be clear, this is not an issue of multiple insertion of e.g., label value (as in 2 x publish label value) but inserting the same node multiple times:

    #[tokio::test]
    async fn test_insert_duplicate() -> Result<(), AkdError> {
        let mut rng = OsRng;
        let db = AsyncInMemoryDatabase::new();
        let mut azks = Azks::new::<_, Blake3>(&db).await?;

        // Create a random node.
        let node = NodeLabel::random(&mut rng);
        let mut input = [0u8; 32];
        rng.fill_bytes(&mut input);
        let input = Blake3Digest::new(input);

        // Duplicate inserts of the same node.
        azks.insert_leaf::<_, Blake3>(&db, node, input).await?;
        println!("Insert one leaf done.");
        azks.insert_leaf::<_, Blake3>(&db, node, input).await?;

        Ok(())
    }

from akd.

slawlor avatar slawlor commented on April 19, 2024

I mean since the public contract of the API it to only interact with the Directory struct, maybe it's worthwhile to just scan for duplicate leaves in the publish(...) call, and throw some error there. I understand we'd like a less cryptic error on the Azks insertion operation, but if we've already trimmed out duplicate leaves I don't see how we'd get duplicate nodes.

Is there anywhere in the lib where this error case is specifically handled? Like in a match or an if let for example? That would be worthwhile to identify, at least with a comment, but it seems like it might be difficult to assert that a direction is none error is a duplicate node error...

from akd.

eozturk1 avatar eozturk1 commented on April 19, 2024

I am not aware of any such locations where we specifically say the error is due to duplicate nodes. It is just that NoDirectionError is thrown at a certain location on the code if we insert the same node multiple times -- but I am not sure whether that code is reached there are duplicate nodes.

One thing we could do is to not insert duplicate nodes in the tests?

@kevinlewi, should we investigate this further? Any pointers on what to look for to identify duplicate nodes?

from akd.

kevinlewi avatar kevinlewi commented on April 19, 2024

Sorry for the delayed reply on this @eozturk1 .

So I guess what I mean is, let's suppose a consumer of this library accidentally attempts to insert duplicate nodes (not just in the tests). Right now, a "NoDirectionError" is thrown, which is ambiguous. Can we make it so that a more instructive error is thrown, that explicitly indicates that a duplicate node was attempted to be inserted?

This might just be a matter of converting the "NoDirectionError" to a new error type like "DuplicateNodeInsertionError". But being careful to only convert this error in the actual event of a duplicate node (since we don't want the DuplicateNodeInsertionError to be thrown when something else unrelated goes wrong).

Hope that makes sense!

from akd.

kevinlewi avatar kevinlewi commented on April 19, 2024

No longer relevant since we handle directory publishing with versioning

from akd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.