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 raw entries interface to ledger for getting slices as [u8] #1465

Merged
merged 1 commit into from
Oct 11, 2018

Conversation

sakridge
Copy link
Member

No description provided.

@sakridge sakridge requested a review from rob-solana October 10, 2018 19:19
src/ledger.rs Outdated
file.seek(SeekFrom::Start(at))?;

let len = deserialize_from(file.take(SIZEOF_U64)).map_err(err_bincode_to_io)?;
trace!("entry_at({}) len: {}", at, len);
let len_size = size_of::<u64>();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you'd have less code if you used the index file to add up all the lengths first...

Copy link
Member Author

Choose a reason for hiding this comment

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

yea.. thought of that. It's some extra reads but probably insignificant.

Copy link
Contributor

Choose a reason for hiding this comment

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

a lot less math and deserialization, too

Copy link
Member Author

Choose a reason for hiding this comment

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

Well I wrote it using the index, it didn't come out a lot better, mostly because I couldn't think of an elegant way to handle the last entry which you don't know the length of using the next one because there is no next one.

@sakridge sakridge force-pushed the entry_as_bytes branch 2 times, most recently from f1331c7 to 8d0b423 Compare October 10, 2018 23:19
Copy link
Contributor

@rob-solana rob-solana left a comment

Choose a reason for hiding this comment

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

I don't need to hold this up, the ledger is unlikely to stick in its current format for more than another few weeks, I fear.

My apologies for not being more clear: I was suggesting the index file could be used to get the first entry and last entry offsets from the index file (2 index reads). Then you'd read the length of the last entry from the data file, then you read from first offset to last offset + last length. 4 reads total no matter how many entries.

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.

2 participants