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

Unchecked cleanup #3600

Merged
merged 9 commits into from
Dec 13, 2021
Merged

Unchecked cleanup #3600

merged 9 commits into from
Dec 13, 2021

Conversation

clemahieu
Copy link
Contributor

This is a series of commits in preparation for adding the unchecked_map ADT.

Each commit is best reviewed individually.

…d_ptr<nano::block> upcast. This allows it to be implicitly convertible to nano::unchecked_info through a conversion-constructor.
Since the hash in unchecked_key must always match the block hash of the block in unchecked_info, put don't directly accept unchecked_key values and instead infers it from the block in unchecked_info directly. Only the dependency needs to be passed in.
…ally ordered instead of totally ordered which doesn't match lmdb behavior. It's not established this has a performance impact and this table is a candidate for using a disk based hash table for superior performance as it doesn't need atomic guarantees.
…unction nano::unchecked_store::equal_range which returns a pair of iterators covering keys equal to the given dependency.
… iterators covering all items in the unchecked store.
@clemahieu clemahieu requested review from dsiganos and thsfs December 10, 2021 13:10
@@ -352,7 +352,7 @@ TEST (bootstrap, simple)
nano::logger_mt logger;
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
ASSERT_TRUE (!store->init_error ());
auto block1 (std::make_shared<nano::send_block> (0, 1, 2, nano::keypair ().prv, 4, 5));
std::shared_ptr<nano::block> block1 = std::make_shared<nano::send_block> (0, 1, 2, nano::keypair ().prv, 4, 5);
Copy link
Contributor

Choose a reason for hiding this comment

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

This clean up looks good, but since you touched the lines anyway, why not auto block = std::make_shared...? Not really important but just in the spirit of if cleaning it up, clean it all the way :D.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one specifically is because std::shared_ptrnano::send_block won't implicitly convert to unchecked_info when passed to unchecked_store::put. It won't do an upcast and also an implicit conversion.

send5->signature.bytes[31] ^= 0x1;
auto signature = send5->block_signature ();
signature.bytes[31] ^= 0x1;
send5->signature_set (signature);
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree it's more clean to get the signature, touch it, then set it back, but was there a functional problem with changing it in-place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we're holding a pointer to nano::block instead of the specific block type, the signature field is no longer directly accessible.

@theohax
Copy link
Contributor

theohax commented Dec 10, 2021

Looks good to me; also, reviewing commits individually turned out to be really helpful, so I recommend that other reviewers do that.

@clemahieu clemahieu added this to the V24.0 milestone Dec 10, 2021
@clemahieu clemahieu merged commit 909aff4 into develop Dec 13, 2021
@clemahieu clemahieu deleted the unchecked_cleanup branch December 13, 2021 13:02
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