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

Add comment for clear_unconfirmed_slot() in blockstore.rs #21837

Merged
merged 1 commit into from
Dec 15, 2021
Merged

Add comment for clear_unconfirmed_slot() in blockstore.rs #21837

merged 1 commit into from
Dec 15, 2021

Conversation

yhchiang-sol
Copy link
Contributor

Summary of Changes

Add comment block for clear_unconfirmed_slot() in blockstore.rs
explaining what it does and which column family it modifies.

@@ -967,6 +967,18 @@ impl Blockstore {
Ok((newly_completed_data_sets, inserted_indices))
}

/**
* Range-delete all entries which prefix matches the specified slot and
* clear all the related metadata except its next_slots.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would specify metadata in the SlotMeta struct, since the other column being deleted families are also technically metadata

carllin
carllin previously approved these changes Dec 13, 2021
@mergify mergify bot dismissed carllin’s stale review December 13, 2021 21:20

Pull request has been modified.

@steviez
Copy link
Contributor

steviez commented Dec 13, 2021

I think you should use

/// documentation line 1
/// documentation line 2
/// ...

over

/**
 * documentation line 1
 * documentation line 2
 * ...
 */

for at least for pub functions. Documentation gets generated for the /// lines above and included docs.rs page. It is hard to say how many people may actually use this, but you can see what did / didn't get included by viewing:
https://docs.rs/solana-ledger/latest/solana_ledger/blockstore/struct.Blockstore.html

There aren't any in this PR, but for the other PR's that use @param, it looks like the preferred method is doing something like:

/// `program_name` will also used to locate the BPF shared object in the current or fixtures

Here's the Rust documentation on this too:
https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html

@codecov
Copy link

codecov bot commented Dec 14, 2021

Codecov Report

Merging #21837 (a4f94af) into master (033106e) will decrease coverage by 0.0%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##           master   #21837     +/-   ##
=========================================
- Coverage    81.3%    81.3%   -0.1%     
=========================================
  Files         516      516             
  Lines      144217   144217             
=========================================
- Hits       117268   117251     -17     
- Misses      26949    26966     +17     

steviez
steviez previously approved these changes Dec 14, 2021
Copy link
Contributor

@steviez steviez left a comment

Choose a reason for hiding this comment

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

The content looks good to me; just the formatting changes to make it match Rust convention please !

@yhchiang-sol
Copy link
Contributor Author

Thanks for the useful reference, @steviez. I will fix all the styles before merging the PRs.

Here's the Rust documentation on this too: https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html

I was referring to the rust comment style mentioned here: https://doc.rust-lang.org/reference/comments.html, where it says:

OUTER_LINE_DOC :
   /// (~/ ~[\n IsolatedCR]*)?

OUTER_BLOCK_DOC :
   /** (~* | BlockCommentOrDoc ) (BlockCommentOrDoc | ~[*/ IsolatedCR])* */

Since the comment is a block comment describing a function, I think it's probably better to use/** */. If we only have one or two lines, then /// is preferred.

Btw, can I know how I can compile/find the document into an html file so that I can see how it looks like?

@steviez
Copy link
Contributor

steviez commented Dec 14, 2021

I was referring to the rust comment style mentioned here: https://doc.rust-lang.org/reference/comments.html, where it says:

Nice, I actually hadn't seen this before so thanks for sharing!

Since the comment is a block comment describing a function, I think it's probably better to use/** */. If we only have one or two lines, then /// is preferred.

I don't have a strong preference one way or the other. It looks like core rust libraries use /// across the board (ie such as here). I guess more than anything, I prefer consistency and I don't think I've seen use of block comments elsewhere in monorepo (not that that is a reason not to)

Btw, can I know how I can compile/find the document into an html file so that I can see how it looks like?
For the documentation that gets scraped from source, you can just do that through cargo. Try:

cargo doc --no-deps --open

The directions at the README here are for building the docs at https://docs.solana.com/

@yhchiang-sol
Copy link
Contributor Author

I guess more than anything, I prefer consistency and I don't think I've seen use of block comments elsewhere in monorepo (not that that is a reason not to)

Definitely! I am just double-checking on what is the mostly-used style in Rust.

https://doc.rust-lang.org/src/alloc/vec/mod.rs.html#410-426

This is a great reference! I will follow the style here.

@mergify mergify bot dismissed steviez’s stale review December 14, 2021 08:05

Pull request has been modified.

@yhchiang-sol yhchiang-sol merged commit 71b12b1 into solana-labs:master Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants